るりまサーチ

最速Rubyリファレンスマニュアル検索!
600件ヒット [1-100件を表示] (0.050秒)

別のキーワード

  1. openssl p
  2. openssl p=
  3. fileutils mkdir_p
  4. kernel $-p
  5. kernel p

ライブラリ

キーワード

検索結果

<< 1 2 3 ... > >>

Kernel$$stdout -> object (36199.0)

標準出力です。

... Kernel.#print、Kernel.#puts や
Kernel.#p
などのデフォルトの出力先となります。
初期値は Object::STDOUT です。
コマンドラインオプションオプション -i を指定した場合には
読み込み元と同じ名前のファイルを表します。

$stdout
...
...レクトしたいときには、
以下のように $stdout に代入すれば十分です。

//emlist[例][ruby]{
# 標準出力の出力先を /tmp/foo に変更
$stdout
= File.open("/tmp/foo", "w")
p
uts "foo" # 出力する
$stdout
= STDOUT # 元に戻す
//}

自プロセスだけで...
...eopen を使います。

//emlist[例][ruby]{
STDOUT.reopen("/tmp/foo", "w")
//}

また、リダイレクトしたあと
出力先をまた元に戻したい場合は以下のようにします。

//emlist[例][ruby]{
stdout_old = $stdout.dup # 元の $stdout を保存する
$stdout
.reopen...

Kernel$$-p -> bool (27119.0)

コマンドラインオプション -p を指定したとき true に設定されます。 この変数には代入できません。

...コマンドラインオプション -p を指定したとき true に設定されます。
この変数には代入できません。

この変数はグローバルスコープです。

@see spec/rubycmd...

Kernel$$DEFAULT_OUTPUT -> IO (27114.0)

$> の別名

...$> の別名

require "English"

dout = $DEFAULT_OUTPUT.dup
$DEFAULT_OUTPUT.reopen("out.txt", "w")
p
rint "foo"
$DEFAULT_OUTPUT.close
$DEFAULT_OUTPUT = dout
p
"bar" # => bar
p
File.read("out.txt") #=> foo...

Kernel$$FIELD_SEPARATOR -> String | nil (27114.0)

$; の別名

...$; の別名

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$$DEFAULT_INPUT -> IO (27108.0)

$< の別名

...$< の別名

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$$ERROR_POSITION -> [String] | nil (27108.0)

$@ の別名

...$@ の別名

require "English"
class SomethingError < StandardError; end

begin
raise SomethingError
rescue
p
$ERROR_POSITION #=> ["sample.rb:5"]
end...

Kernel$$INPUT_LINE_NUMBER -> Integer (27108.0)

$. の別名

...$. の別名

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 (27108.0)

$/ の別名

...$/ の別名

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_PAREN_MATCH -> String | nil (27108.0)

$+ の別名

...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://localhost...
.../link.html>link</a></td> </tr>
#enf of sample.rb

$ ruby sample.rb
"http://localhost/a.jpg"
"link"...
<< 1 2 3 ... > >>