るりまサーチ

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

別のキーワード

  1. _builtin gets
  2. irb/input-method gets
  3. io gets
  4. argf.class gets
  5. csv gets

ライブラリ

キーワード

検索結果

Kernel$$stdin -> object (49.0)

標準入力です。

...$stdin = File.open("/tmp/foo", "r")
gets
# 入力する
$stdin = STDIN # 元に戻す
//}

ただし、Kernel.#gets など、特定の組み込みメソッドは
$stdin オブジェクトにメソッドを転送して実装されています。
従って、Kernel.#gets などが正...
...していなければいけません。

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"
//}

自プロセスだけ...
...IO#reopen を使います。

//emlist[例][ruby]{
$stdin.reopen("/tmp/foo")
//}

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

//emlist[例][ruby]{
stdin_old = $stdin.dup # 元の $stdin を保存する
$stdin.reopen("/tm...

Kernel#file(*args) { ... } -> Rake::FileTask (19.0)

ファイルタスクを定義します。

...ファイル名を指定します。

例:
file "config.cfg" => ["config.template"] do
open
("config.cfg", "w") do |outfile|
open
("config.template") do |infile|
while line = infile.gets
outfile.puts line
end
end
end
end

@see Rake::Task.defin...