種類
- 特異メソッド (187)
- インスタンスメソッド (88)
ライブラリ
- ビルトイン (275)
検索結果
先頭5件
-
IO
# print(*arg) -> nil (26126.0) -
引数を IO ポートに順に出力します。引数を省略した場合は、$_ を出力します。
...引数を IO ポートに順に出力します。引数を省略した場合は、$_ を出力します。
@param arg Kernel.#print と同じです。
@raise IOError 自身が書き込み用にオープンされていなければ発生します。
@raise Errno::EXXX 出力に失敗した場合......に発生します。
//emlist[例][ruby]{
$stdout.print("This is ", 100, " percent.\n") # => This is 100 percent.
//}
@see Kernel.#print... -
IO
# printf(format , *arg) -> nil (14113.0) -
C 言語の printf と同じように、format に従い引数 を文字列に変換して、self に出力します。
...の printf と同じように、format に従い引数
を文字列に変換して、self に出力します。
第一引数に IO を指定できないこと、引数を省略できないことを除けば Kernel.#printf と同じです。
@param format Kernel.#printf と同じです。print_form......at を参照してください。
@param arg Kernel.#printf と同じです。
@raise IOError 自身が書き込み用にオープンされていなければ発生します。
@raise Errno::EXXX 出力に失敗した場合に発生します。
@see Kernel.#printf... -
IO
. foreach(path , rs = $ / , chomp: false) -> Enumerator (8019.0) -
path で指定されたファイルの各行を引数としてブロックを繰り返し実行します。 path のオープンに成功すれば nil を返します。
...ます。
@raise Errno::EXXX path のオープンに失敗した場合、発生します。
//emlist[例:rs 指定なし][ruby]{
IO.write("testfile", "line1\nline2,\nline3\n")
IO.foreach("testfile") # => #<Enumerator: IO:foreach("testfile")>
IO.foreach("testfile") { |x| print "GOT ", x }
# => GOT......]{
IO.write("testfile", "line1,line2,line3")
IO.foreach("testfile", ",") { |x| puts "GOT #{x}" }
# => GOT line1,
# GOT line2,
# GOT line3
//}
//emlist[例: 各行の末尾から "\n", "\r", または "\r\n" を取り除く(chomp = true)][ruby]{
IO.write("testfile", "line1\nline2,\nline3\n")
IO.......foreach("testfile", chomp: true) { |x| print "GOT ", x }
# => GOT line1GOT line2,GOT line3
//}
@see $/... -
IO
. foreach(path , rs = $ / , chomp: false) {|line| . . . } -> nil (8019.0) -
path で指定されたファイルの各行を引数としてブロックを繰り返し実行します。 path のオープンに成功すれば nil を返します。
...ます。
@raise Errno::EXXX path のオープンに失敗した場合、発生します。
//emlist[例:rs 指定なし][ruby]{
IO.write("testfile", "line1\nline2,\nline3\n")
IO.foreach("testfile") # => #<Enumerator: IO:foreach("testfile")>
IO.foreach("testfile") { |x| print "GOT ", x }
# => GOT......]{
IO.write("testfile", "line1,line2,line3")
IO.foreach("testfile", ",") { |x| puts "GOT #{x}" }
# => GOT line1,
# GOT line2,
# GOT line3
//}
//emlist[例: 各行の末尾から "\n", "\r", または "\r\n" を取り除く(chomp = true)][ruby]{
IO.write("testfile", "line1\nline2,\nline3\n")
IO.......foreach("testfile", chomp: true) { |x| print "GOT ", x }
# => GOT line1GOT line2,GOT line3
//}
@see $/... -
IO
. popen("-" , mode = "r" , opt={}) -> IO (8014.0) -
第一引数に文字列 "-" が指定された時、fork(2) を 行い子プロセスの標準入出力との間にパイプラインを確立します。 親プロセスでは IO オブジェクトを返し、子プロセスでは nil を返します。
...親プロセスでは IO オブジェクトを返し、子プロセスでは
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...... IO オブジェクトを引数に
ブロックを実行し、その結果を返します。ブロックの実行後、生成したパイ
プは自動的にクローズされます。
子プロセスでは nil を引数にブロックを実行し終了します。
p IO.popen("-", "r+") {|io|......if io # parent
io.puts "foo"
io.gets
else # child
s = gets
puts "child output: " + s
end
}
# => "child output: foo\n"
opt ではエンコーディングの設定やプロセス起動のためのオプションが指定できます。
IO.new や Kernel.#spa... -
IO
. popen("-" , mode = "r" , opt={}) {|io| . . . } -> object (8014.0) -
第一引数に文字列 "-" が指定された時、fork(2) を 行い子プロセスの標準入出力との間にパイプラインを確立します。 親プロセスでは IO オブジェクトを返し、子プロセスでは nil を返します。
...親プロセスでは IO オブジェクトを返し、子プロセスでは
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...... IO オブジェクトを引数に
ブロックを実行し、その結果を返します。ブロックの実行後、生成したパイ
プは自動的にクローズされます。
子プロセスでは nil を引数にブロックを実行し終了します。
p IO.popen("-", "r+") {|io|......if io # parent
io.puts "foo"
io.gets
else # child
s = gets
puts "child output: " + s
end
}
# => "child output: foo\n"
opt ではエンコーディングの設定やプロセス起動のためのオプションが指定できます。
IO.new や Kernel.#spa... -
IO
. popen(env , "-" , mode = "r" , opt={}) -> IO (8014.0) -
第一引数に文字列 "-" が指定された時、fork(2) を 行い子プロセスの標準入出力との間にパイプラインを確立します。 親プロセスでは IO オブジェクトを返し、子プロセスでは nil を返します。
...親プロセスでは IO オブジェクトを返し、子プロセスでは
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...... IO オブジェクトを引数に
ブロックを実行し、その結果を返します。ブロックの実行後、生成したパイ
プは自動的にクローズされます。
子プロセスでは nil を引数にブロックを実行し終了します。
p IO.popen("-", "r+") {|io|......if io # parent
io.puts "foo"
io.gets
else # child
s = gets
puts "child output: " + s
end
}
# => "child output: foo\n"
opt ではエンコーディングの設定やプロセス起動のためのオプションが指定できます。
IO.new や Kernel.#spa... -
IO
. popen(env , "-" , mode = "r" , opt={}) {|io| . . . } -> object (8014.0) -
第一引数に文字列 "-" が指定された時、fork(2) を 行い子プロセスの標準入出力との間にパイプラインを確立します。 親プロセスでは IO オブジェクトを返し、子プロセスでは nil を返します。
...親プロセスでは IO オブジェクトを返し、子プロセスでは
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...... IO オブジェクトを引数に
ブロックを実行し、その結果を返します。ブロックの実行後、生成したパイ
プは自動的にクローズされます。
子プロセスでは nil を引数にブロックを実行し終了します。
p IO.popen("-", "r+") {|io|......if io # parent
io.puts "foo"
io.gets
else # child
s = gets
puts "child output: " + s
end
}
# => "child output: foo\n"
opt ではエンコーディングの設定やプロセス起動のためのオプションが指定できます。
IO.new や Kernel.#spa... -
IO
# close _ write -> nil (8013.0) -
書き込み用の IO を close します。
... IO を close します。
@raise IOError 自身が書き込み用にオープンされていなければ発生します。
@raise Errno::EXXX close に失敗した場合に発生します。
//emlist[例][ruby]{
f = IO.popen("/bin/sh","r+") do |f|
f.close_write
# f.print "nowhere" # => IOEr......ror: not opened for writing
end
//}
@see IO#close, IO#closed?, IO#close_read......の IO を close します。
既に close されていた場合には単に無視されます。
@raise IOError 自身が書き込み用にオープンされていなければ発生します。
@raise Errno::EXXX close に失敗した場合に発生します。
//emlist[例][ruby]{
f = IO.popen......("/bin/sh","r+") do |f|
f.close_write
# f.print "nowhere" # => IOError: not opened for writing
end
//}
@see IO#close, IO#closed?, IO#close_read... -
IO
# flush -> self (8013.0) -
IO ポートの内部バッファをフラッシュします。
...
IO ポートの内部バッファをフラッシュします。
このメソッドを使ったとき、即座にメタデータを更新することは保証されません(特にWindowsで)。
即座にメタデータも更新したいときは IO#fsync を使います。
@raise IOError 自身......込み用にオープンされていなければ発生します。
@raise Errno::EXXX fflush(3) が失敗した場合に発生します。
//emlist[例][ruby]{
require "tempfile"
Tempfile.open("testtmpfile") do |f|
f.print "test"
File.read(f.path) # => ""
f.flush
File.read(f.path) # => "t...