キーワード
-
$ ARGV (3) -
$ CHILD _ STATUS (3) -
$ DEFAULT _ INPUT (3) -
$ DEFAULT _ OUTPUT (3) -
$ ERROR _ INFO (3) -
$ ERROR _ POSITION (3) -
$ FIELD _ SEPARATOR (3) -
$ FS (3) -
$ IGNORECASE (3) -
$ INPUT _ LINE _ NUMBER (3) -
$ INPUT _ RECORD _ SEPARATOR (3) -
$ LAST _ MATCH _ INFO (3) -
$ LAST _ PAREN _ MATCH (3) -
$ LAST _ READ _ LINE (3) -
$ MATCH (3) -
$ NR (3) -
$ OFS (3) -
$ ORS (3) -
$ OUTPUT _ FIELD _ SEPARATOR (3) -
$ OUTPUT _ RECORD _ SEPARATOR (3) -
$ PID (3) -
$ POSTMATCH (3) -
$ PREMATCH (3) -
$ PROCESS _ ID (3) -
$ PROGRAM _ NAME (3) -
$ RS (3)
検索結果
先頭5件
-
Kernel
$ $ ARGV -> [String] (3) -
$* の別名
...$* の別名
require "English"
p $ARGV
# end of sample.rb
ruby sample.rb 31 /home/hoge/fuga.txt
#=> ["31", "/home/hoge/fuga.txt"]... -
Kernel
$ $ CHILD _ STATUS -> Process :: Status | nil (3) -
$? の別名
...$? の別名
require "English"
out = `wget http://www2.ruby-lang.org/ja/LICENSE.txt -O - 2>/dev/null`
if $CHILD_STATUS.to_i == 0
print "wget success\n"
out.split(/\n/).each { |line|
printf "%s\n", line
}
else
print "wget failed\n"
end... -
Kernel
$ $ DEFAULT _ INPUT -> IO (3) -
$< の別名 require "English" while line = $DEFAULT_INPUT.gets p line end # end of sample.rb
...$< の別名
require "English"
while line = $DEFAULT_INPUT.gets
p line
end
# end of sample.rb
ruby sample.rb < /etc/passwd
# => "hoge:x:500:501::/home/hoge:/bin/bash\n"
...... -
Kernel
$ $ DEFAULT _ OUTPUT -> IO (3) -
$> の別名 require "English"
...$> の別名
require "English"
dout = $DEFAULT_OUTPUT.dup
$DEFAULT_OUTPUT.reopen("out.txt", "w")
print "foo"
$DEFAULT_OUTPUT.close
$DEFAULT_OUTPUT = dout
p "bar" # => bar
p File.read("out.txt") #=> foo... -
Kernel
$ $ ERROR _ INFO -> Exception (3) -
$! の別名
...$! の別名
require "English"
class SomethingError < StandardError; end
begin
raise SomethingError
rescue
p $ERROR_INFO.backtrace #=> ["sample.rb:5"]
p $ERROR_INFO.to_s #=> "SomethingError"
end... -
Kernel
$ $ ERROR _ POSITION -> [String] | nil (3) -
$@ の別名
...$@ の別名
require "English"
class SomethingError < StandardError; end
begin
raise SomethingError
rescue
p $ERROR_POSITION #=> ["sample.rb:5"]
end... -
Kernel
$ $ FIELD _ SEPARATOR -> String | nil (3) -
$; の別名
...$; の別名
require "English"
str = "hoge,fuga,ugo,bar,foo"
p str.split #=> ["hoge,fuga,ugo,bar,foo"]
$FIELD_SEPARATOR = ","
p str.split #=> ["hoge", "fuga", "ugo", "bar", "foo"]... -
Kernel
$ $ FS -> String | nil (3) -
$; の別名
...$; の別名
require "English"
str = "hoge,fuga,ugo,bar,foo"
p str.split #=> ["hoge,fuga,ugo,bar,foo"]
$FIELD_SEPARATOR = ","
p str.split #=> ["hoge", "fuga", "ugo", "bar", "foo"]... -
Kernel
$ $ IGNORECASE -> bool (3) -
非推奨(obsolete): この変数は将来のバージョンで削除される予定です。
...非推奨(obsolete): この変数は将来のバージョンで削除される予定です。
$= の別名
require "English"
$IGNORECASE=true
str_l = "FOOBAR"
str_s = "foobar"
if str_l == str_s
p "#{str_l} equal to #{str_s}" #=> "FOOBAR equal to foobar"
end... -
Kernel
$ $ INPUT _ LINE _ NUMBER -> Fixnum (3) -
$. の別名
...$. の別名
1 e
2 f
3 g
4 h
5 i
# end of a.txt
require "English"
File.foreach(ARGV.at(0)){|line|
# read line
}
p $INPUT_LINE_NUMBER
# end of sample.rb
ruby sample.rb a.txt
#=> 5... -
Kernel
$ $ INPUT _ RECORD _ SEPARATOR -> String | nil (3) -
$/ の別名
...$/ の別名
require "English"
$INPUT_RECORD_SEPARATOR = '|'
array = []
while line = DATA.gets
array << line
end
p array #=> ["ugo|", "ego|", "fogo\n"]
__END__
ugo|ego|fogo... -
Kernel
$ $ LAST _ MATCH _ INFO -> MatchData (3) -
$~ の別名
...$~ の別名
require "English"
str = "<a href=http://www2.ruby-lang.org/ja/LICENSE.txt>license</a>"
if /<a href=(.+?)>/ =~ str
p $LAST_MATCH_INFO[0] #=> "<a href=http://www2.ruby-lang.org/ja/LICENSE.txt>"
p $LAST_MATCH_INFO[1] #=> "http://www2.ruby-lang.org/ja/LICENSE.txt"
p $L... -
Kernel
$ $ LAST _ PAREN _ MATCH -> String | nil (3) -
$+ の別名
...$+ の別名
require "English"
r1 = Regexp.compile("<img src=(http:.+?)>")
r2 = Regexp.compile("<a href=(http|ftp).+?>(.+?)</a>")
while line = DATA.gets
[ r1, r2 ].each {|rep|
rep =~ line
p $+
}
end
__END__
<tr> <td><img src=http://localhost/a.jpg></td> <td>ikko... -
Kernel
$ $ LAST _ READ _ LINE -> String | nil (3) -
$_ の別名 1 e 2 f 3 g 4 h 5 i # end of a.txt
...$_ の別名
1 e
2 f
3 g
4 h
5 i
# end of a.txt
ruby -rEnglish -ne'p $LAST_READ_LINE' a.txt
#=>
"1 e\n"
"2 f\n"
"3 g\n"
"4 h\n"
"5 i\n"... -
Kernel
$ $ MATCH -> String | nil (3) -
$& の別名
...$& の別名
require "English"
str = 'hoge,foo,bar,hee,hoo'
/(foo|bar)/ =~ str
p $MATCH #=> "foo"... -
Kernel
$ $ NR -> Fixnum (3) -
$. の別名
...$. の別名
1 e
2 f
3 g
4 h
5 i
# end of a.txt
require "English"
File.foreach(ARGV.at(0)){|line|
# read line
}
p $INPUT_LINE_NUMBER
# end of sample.rb
ruby sample.rb a.txt
#=> 5... -
Kernel
$ $ OFS -> String | nil (3) -
$, の別名
...$, の別名
require "English"
array = %w|hoge fuga ugo bar foo|
p array.join #=> "hogefugaugobarfoo"
$OUTPUT_FIELD_SEPARATOR = ","
p array.join #=> "hoge,fuga,ugo,bar,foo"... -
Kernel
$ $ ORS -> String | nil (3) -
$\ の別名
...$\ の別名
require "English"
print "hoge\nhuga\n"
$OUTPUT_RECORD_SEPARATOR = "\n"
print "fuge"
print "ugo"
# end of sample.rb
ruby sample.rb
hoge
huga
fuge
ugo... -
Kernel
$ $ OUTPUT _ FIELD _ SEPARATOR -> String | nil (3) -
$, の別名
...$, の別名
require "English"
array = %w|hoge fuga ugo bar foo|
p array.join #=> "hogefugaugobarfoo"
$OUTPUT_FIELD_SEPARATOR = ","
p array.join #=> "hoge,fuga,ugo,bar,foo"... -
Kernel
$ $ OUTPUT _ RECORD _ SEPARATOR -> String | nil (3) -
$\ の別名
...$\ の別名
require "English"
print "hoge\nhuga\n"
$OUTPUT_RECORD_SEPARATOR = "\n"
print "fuge"
print "ugo"
# end of sample.rb
ruby sample.rb
hoge
huga
fuge
ugo... -
Kernel
$ $ PID -> Fixnum (3) -
$$ の別名 require "English"
...$$ の別名
require "English"
p sprintf("something%s", $PID) #=> "something5543" など... -
Kernel
$ $ POSTMATCH -> String | nil (3) -
$' の別名
...$' の別名
require "English"
str = 'hoge,foo,bar,hee,hoo'
/foo/ =~ str
p $POSTMATCH #=> ",bar,hee,hoo"... -
Kernel
$ $ PREMATCH -> String | nil (3) -
$` の別名
...$` の別名
require "English"
str = 'hoge,foo,bar,hee,hoo'
/foo/ =~ str
p $PREMATCH #=> "hoge,"... -
Kernel
$ $ PROCESS _ ID -> Fixnum (3) -
$$ の別名 require "English"
...$$ の別名
require "English"
p sprintf("something%s", $PID) #=> "something5543" など... -
Kernel
$ $ PROGRAM _ NAME -> String (3) -
$0 の別名
...$0 の別名
require "English"
p $PROGRAM_NAME
#end of sample.rb
ruby sample.rb #=> "sample.rb"
ruby ./sample.rb #=> "./sample.rb"
ruby /home/hoge/bin/sample.rb #=> "/home/hoge/bin/sample.rb"... -
Kernel
$ $ RS -> String | nil (3) -
$/ の別名
...$/ の別名
require "English"
$INPUT_RECORD_SEPARATOR = '|'
array = []
while line = DATA.gets
array << line
end
p array #=> ["ugo|", "ego|", "fogo\n"]
__END__
ugo|ego|fogo...
