るりまサーチ

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

別のキーワード

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

クラス

  • IO (462)

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

IO#gets(limit) -> String | nil (26123.0)

一行読み込んで、読み込みに成功した時にはその文字列を返します。 EOF に到達した時には nil を返します。

...用にオープンされていなければ発生します。

f = File.new("oneline_file")
f.gets #=> "This is line one\n"
$_ #=> "This is line one\n"
f.gets #=> nil
$_ #=> nil...

IO#gets(limit, chomp: false) -> String | nil (26123.0)

一行読み込んで、読み込みに成功した時にはその文字列を返します。 EOF に到達した時には nil を返します。

...用にオープンされていなければ発生します。

f = File.new("oneline_file")
f.gets #=> "This is line one\n"
$_ #=> "This is line one\n"
f.gets #=> nil
$_ #=> nil...

IO#gets(rs = $/) -> String | nil (26123.0)

一行読み込んで、読み込みに成功した時にはその文字列を返します。 EOF に到達した時には nil を返します。

...用にオープンされていなければ発生します。

f = File.new("oneline_file")
f.gets #=> "This is line one\n"
$_ #=> "This is line one\n"
f.gets #=> nil
$_ #=> nil...

IO#gets(rs = $/, chomp: false) -> String | nil (26123.0)

一行読み込んで、読み込みに成功した時にはその文字列を返します。 EOF に到達した時には nil を返します。

...用にオープンされていなければ発生します。

f = File.new("oneline_file")
f.gets #=> "This is line one\n"
$_ #=> "This is line one\n"
f.gets #=> nil
$_ #=> nil...

IO#gets(rs, limit) -> String | nil (26123.0)

一行読み込んで、読み込みに成功した時にはその文字列を返します。 EOF に到達した時には nil を返します。

...用にオープンされていなければ発生します。

f = File.new("oneline_file")
f.gets #=> "This is line one\n"
$_ #=> "This is line one\n"
f.gets #=> nil
$_ #=> nil...

絞り込み条件を変える

IO#gets(rs, limit, chomp: false) -> String | nil (26123.0)

一行読み込んで、読み込みに成功した時にはその文字列を返します。 EOF に到達した時には nil を返します。

...用にオープンされていなければ発生します。

f = File.new("oneline_file")
f.gets #=> "This is line one\n"
$_ #=> "This is line one\n"
f.gets #=> nil
$_ #=> nil...

IO#lineno -> Integer (8052.0)

現在の行番号を整数で返します。実際には IO#gets が呼ばれた回数です。 改行以外のセパレータで gets が呼ばれた場合など、実際の行番号と異なる場合があります。

...実際には IO#gets が呼ばれた回数です。
改行以外のセパレータで gets が呼ばれた場合など、実際の行番号と異なる場合があります。

@raise IOError 読み込み用にオープンされていなければ発生します。

f = File.new("testfile")
f.lin...
...eno #=> 0
f.gets #=> "This is line one\n"
f.lineno #=> 1
f.gets #=> "This is line two\n"
f.lineno #=> 2

@see $....

Kernel$$stdin -> object (8050.0)

標準入力です。

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

自プロセスだけ...
...][ruby]{
stdin_old = $stdin.dup # 元の $stdin を保存する
$stdout.reopen("/tmp/foo") # $stdin を /tmp/foo にリダイレクトする
gets
# /tmp/foo から入力
$stdin.reopen stdin_old # 元に戻す
//}

$stdin はグローバルスコープです。...

IO.popen("-", mode = "r", opt={}) -> IO (8043.0)

第一引数に文字列 "-" が指定された時、fork(2) を 行い子プロセスの標準入出力との間にパイプラインを確立します。 親プロセスでは IO オブジェクトを返し、子プロセスでは nil を返します。

...では
nil を返します。

io = IO.popen("-", "r+")
if io # parent
io.puts "foo"
p io.gets # => "child output: foo\n"
io.close
else # child
s = gets
print "child output: " + s
exit
end

ブロックを与えられた場合、親プロセス...
...nt
io.puts "foo"
io.gets
else # child
s = gets
puts "child output: " + s
end
}
# => "child output: foo\n"

opt ではエンコーディングの設定やプロセス起動のためのオプションが指定できます。
IO.new や Kernel.#spawn で指定で...
...ポートのモードを指定します。mode の詳細は Kernel.#open 参照して下さい。
@param opt エンコーディングなどを設定するオプション引数(see IO.new)

@raise Errno::EXXX パイプ、あるいは子プロセスの生成に失敗した場合に発生します。...

IO.popen("-", mode = "r", opt={}) {|io| ... } -> object (8043.0)

第一引数に文字列 "-" が指定された時、fork(2) を 行い子プロセスの標準入出力との間にパイプラインを確立します。 親プロセスでは IO オブジェクトを返し、子プロセスでは nil を返します。

...では
nil を返します。

io = IO.popen("-", "r+")
if io # parent
io.puts "foo"
p io.gets # => "child output: foo\n"
io.close
else # child
s = gets
print "child output: " + s
exit
end

ブロックを与えられた場合、親プロセス...
...nt
io.puts "foo"
io.gets
else # child
s = gets
puts "child output: " + s
end
}
# => "child output: foo\n"

opt ではエンコーディングの設定やプロセス起動のためのオプションが指定できます。
IO.new や Kernel.#spawn で指定で...
...ポートのモードを指定します。mode の詳細は Kernel.#open 参照して下さい。
@param opt エンコーディングなどを設定するオプション引数(see IO.new)

@raise Errno::EXXX パイプ、あるいは子プロセスの生成に失敗した場合に発生します。...

絞り込み条件を変える

IO.popen(env, "-", mode = "r", opt={}) -> IO (8043.0)

第一引数に文字列 "-" が指定された時、fork(2) を 行い子プロセスの標準入出力との間にパイプラインを確立します。 親プロセスでは IO オブジェクトを返し、子プロセスでは nil を返します。

...では
nil を返します。

io = IO.popen("-", "r+")
if io # parent
io.puts "foo"
p io.gets # => "child output: foo\n"
io.close
else # child
s = gets
print "child output: " + s
exit
end

ブロックを与えられた場合、親プロセス...
...nt
io.puts "foo"
io.gets
else # child
s = gets
puts "child output: " + s
end
}
# => "child output: foo\n"

opt ではエンコーディングの設定やプロセス起動のためのオプションが指定できます。
IO.new や Kernel.#spawn で指定で...
...ポートのモードを指定します。mode の詳細は Kernel.#open 参照して下さい。
@param opt エンコーディングなどを設定するオプション引数(see IO.new)

@raise Errno::EXXX パイプ、あるいは子プロセスの生成に失敗した場合に発生します。...

IO.popen(env, "-", mode = "r", opt={}) {|io| ... } -> object (8043.0)

第一引数に文字列 "-" が指定された時、fork(2) を 行い子プロセスの標準入出力との間にパイプラインを確立します。 親プロセスでは IO オブジェクトを返し、子プロセスでは nil を返します。

...では
nil を返します。

io = IO.popen("-", "r+")
if io # parent
io.puts "foo"
p io.gets # => "child output: foo\n"
io.close
else # child
s = gets
print "child output: " + s
exit
end

ブロックを与えられた場合、親プロセス...
...nt
io.puts "foo"
io.gets
else # child
s = gets
puts "child output: " + s
end
}
# => "child output: foo\n"

opt ではエンコーディングの設定やプロセス起動のためのオプションが指定できます。
IO.new や Kernel.#spawn で指定で...
...ポートのモードを指定します。mode の詳細は Kernel.#open 参照して下さい。
@param opt エンコーディングなどを設定するオプション引数(see IO.new)

@raise Errno::EXXX パイプ、あるいは子プロセスの生成に失敗した場合に発生します。...

IO.popen([env = {}, [cmdname, arg0], *args, execopt={}], mode = "r", opt={}) -> IO (8038.0)

サブプロセスを実行し、そのプロセスの標準入出力 との間にパイプラインを確立します。生成したパイプを IO オブジェクトとして返します。

...パイプを IO オブジェクトとして返します。

p io = IO.popen("cat", "r+") # => #<IO:fd 4>
io.puts "foo"
io.close_write
p io.gets # => "foo\n"

サブプロセスを指定する方法は2通りあります。文字列を指定する場合と配列を指定...
...後、生成したパイ
プは自動的にクローズされます。

p IO.popen("cat", "r+") {|io|
io.puts "foo"
io.close_write
io.gets
}
# => "foo\n"


opt でプロセス起動のためのオプションや、パイプ IO オブジェクトの属性(エンコーディングや...
...ンは IO.new と共通です。
つまり、 :external_encoding や :unsetenv_others が指定できます。
オプションの詳しい意味は Kernel.#spawn や IO.new を参照してください。

# nkfプロセスから得られる文字列を EUC-JP と指定する
# IO.new などと...
<< 1 2 3 ... > >>