308件ヒット
[1-100件を表示]
(0.036秒)
種類
- 特異メソッド (187)
- インスタンスメソッド (121)
検索結果
先頭5件
-
IO
# print(*arg) -> nil (18122.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 (6109.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 (15.0) -
path で指定されたファイルの各行を引数としてブロックを繰り返し実行します。 path のオープンに成功すれば nil を返します。
...][ruby]{
IO.write("testfile", "line1\nline2,\nline3\n")
IO.foreach("testfile") # => #<Enumerator: IO:foreach("testfile")>
IO.foreach("testfile") { |x| print "GOT ", x }
# => GOT line1
# GOT line2,
# GOT line3
//}
//emlist[例:カンマを行の区切りに指定( rs = "," )][ruby]{
IO.write("t......
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... -
IO
. foreach(path , rs = $ / , chomp: false) {|line| . . . } -> nil (15.0) -
path で指定されたファイルの各行を引数としてブロックを繰り返し実行します。 path のオープンに成功すれば nil を返します。
...][ruby]{
IO.write("testfile", "line1\nline2,\nline3\n")
IO.foreach("testfile") # => #<Enumerator: IO:foreach("testfile")>
IO.foreach("testfile") { |x| print "GOT ", x }
# => GOT line1
# GOT line2,
# GOT line3
//}
//emlist[例:カンマを行の区切りに指定( rs = "," )][ruby]{
IO.write("t......
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... -
IO
# close _ write -> nil (9.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
# each _ char -> Enumerator (9.0) -
self に含まれる文字を一文字ずつブロックに渡して評価します。
...ません。
ブロックを省略した場合は各文字について繰り返す Enumerator を返します。
@raise IOError self が読み込み用にオープンされていない場合に発生します。
f = File.new("testfile")
f.each_char {|c| print c, ' ' } #=> #<File:testfile>... -
IO
# each _ char {|c| . . . } -> self (9.0) -
self に含まれる文字を一文字ずつブロックに渡して評価します。
...ません。
ブロックを省略した場合は各文字について繰り返す Enumerator を返します。
@raise IOError self が読み込み用にオープンされていない場合に発生します。
f = File.new("testfile")
f.each_char {|c| print c, ' ' } #=> #<File:testfile>... -
IO
# fdatasync -> 0 (9.0) -
IO のすべてのバッファされているデータを直ちにディスクに書き込みます。
...
IO のすべてのバッファされているデータを直ちにディスクに書き込みます。
fdatasync(2) をサポートしていない OS 上では代わりに
IO#fsync を呼びだします。
IO#fsync との違いは fdatasync(2) を参照してください。
@raise NotImplemented......Error fdatasync(2) も fsync(2) も
サポートされていない OS で発生します。
//emlist[例][ruby]{
require "tempfile"
Tempfile.open("testtmpfile") do |f|
f.print "test"
File.read(f.path) # => ""
f.fdatasync
File.read(f.path) # => "test"
end
//}... -
IO
# flush -> self (9.0) -
IO ポートの内部バッファをフラッシュします。
...
IO ポートの内部バッファをフラッシュします。
@raise IOError 自身が書き込み用にオープンされていなければ発生します。
@raise Errno::EXXX fflush(3) が失敗した場合に発生します。
//emlist[例][ruby]{
require "tempfile"
Tempfile.open("testtm......pfile") do |f|
f.print "test"
File.read(f.path) # => ""
f.flush
File.read(f.path) # => "test"
end
//}......
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) # => "test"
end
//}... -
IO
# reopen(path) -> self (9.0) -
path で指定されたファイルにストリームを繋ぎ換えます。
...ぎます。
IO#pos, IO#lineno などはリセットされます。
@param path パスを表す文字列を指定します。
@param mode パスを開く際のモードを文字列で指定します。
@raise Errno::EXXX 失敗した場合に発生します。
//emlist[例][ruby]{
IO.write("test......file", "This is line one\nThis is line two\n")
f1 = File.new("testfile", "a+")
f2 = File.new("testfile")
f1.print("This is line three\n")
f2.readlines # => ["This is line one\n", "This is line two\n"]
f1.close
f2.reopen("testfile", "r") # => #<File:testfile>
f2.readlines...