るりまサーチ

最速Rubyリファレンスマニュアル検索!
11件ヒット [1-11件を表示] (0.080秒)
トップページ > クエリ:_builtin[x] > クエリ:new[x] > クエリ:dup[x] > 種類:変数[x]

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

ライブラリ

モジュール

検索結果

Kernel$$stdin -> object (8013.0)

標準入力です。

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

自プロセスだけでなく、子プロセスの標準入力もリダイレクトしたい...
...リダイレクトしたあと
出力先をまた元に戻したい場合は以下のようにします。

//emlist[例][ruby]{
stdin_old = $stdin.dup # 元の $stdin を保存する
$stdout.reopen("/tmp/foo") # $stdin を /tmp/foo にリダイレクトする
gets #...