48件ヒット
[1-48件を表示]
(0.018秒)
モジュール
- Kernel (48)
キーワード
-
$ CHILD _ STATUS (12) -
$ LAST _ PAREN _ MATCH (12) -
$ _ (12) -
$ stdin (12)
検索結果
先頭4件
-
Kernel
$ $ stdin -> object (13.0) -
標準入力です。
...装していなければいけません。
gets, readline, readlines, getc, readchar, tell, seek,
pos=, rewind, fileno, to_io, eof, each_line, each_byte,
binmode, closed?
//emlist[例][ruby]{
$stdin = Object.new
def $stdin.gets
"foo"
end
p gets() # => "foo"
//}
自プロセスだ... -
Kernel
$ $ CHILD _ STATUS -> Process :: Status | nil (7.0) -
$? の別名
...$? の別名
require "English"
out = `wget https://www.ruby-lang.org/en/about/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
$ $ LAST _ PAREN _ MATCH -> String | nil (7.0) -
$+ の別名
...h"
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>ikkou</td> <td><a href=http://localh... -
Kernel
$ $ _ -> String | nil (7.0) -
最後に Kernel.#gets または Kernel.#readline で読み込んだ文字列です。 EOF に達した場合には、 nil になります。 (覚え方: Perlと同じ)
...RGF
=== 例
example.txt:
foo
bar
baz
このとき、コマンド ruby -e 'print while gets' example.txt は次を出力します
foo
bar
baz
ただし、このプログラムは次のように書く方がよりRuby的です。
//emlist[例][ruby]{
ARGF.each do |line|
print line
end
//}...