This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# -*- coding: UTF-8 -*- | |
# | |
# $ ruby -v | |
# ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux] | |
# | |
x = "xyz" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# -*- coding: UTF-8 -*- | |
# | |
# $ ruby -v | |
# ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux] | |
# | |
x = "xyz" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# -*- coding: UTF-8 -*- | |
# | |
# $ ruby -v | |
# ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux] | |
# | |
x = "xyz" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# -*- coding: UTF-8 -*- | |
# | |
# $ ruby -v | |
# ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux] | |
# | |
p 10 #=> 10 | |
p 1_000 #=> 1000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# -*- coding: UTF-8 -*- | |
x = "world" | |
p <<S #=> "hello, world\n" | |
hello, #{x} | |
S | |
p <<'!' #=> "hello, #{x}\n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: UTF-8 | |
# | |
# $ ruby -v | |
# ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux] | |
# | |
puts "%#x" % "あ".ord #=> 0x3042 | |
p "あ" == "\u3042" #=> true | |
p "\u3042" #=> "あ" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: UTF-8 | |
# | |
# $ ruby -v | |
# ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux] | |
# | |
# | |
# "\C-x" ..... control character | |
# "\M-x" ..... meta character |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# $ ruby -v | |
# ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux] | |
# | |
p $! # OK | |
p $" # OK | |
#p $# ### Syntax Error | |
p $$ # OK | |
#p $% ### Syntax Error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# -*- coding: UTF-8 -*- | |
=begin | |
usage: $ ruby rcat.rb ruby-script.rb | |
=end | |
require 'ripper' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# -*- coding: UTF-8 -*- | |
puts "\e[0m" "escape sequence(0m)" "\e[m" # RESET or NORMAL | |
puts "\e[1m" "escape sequence(1m)" "\e[m" # BRIGHT or BOLD | |
puts "\e[2m" "escape sequence(2m)" "\e[m" | |
puts "\e[3m" "escape sequence(3m)" "\e[m" | |
puts "\e[4m" "escape sequence(4m)" "\e[m" # UNDERLINE | |
puts "\e[5m" "escape sequence(5m)" "\e[m" | |
puts "\e[6m" "escape sequence(6m)" "\e[m" |