ライブラリ
- ビルトイン (789)
キーワード
- advise (11)
- clone (11)
- close (11)
-
close
_ on _ exec= (11) - closed? (11)
- dup (11)
- each (66)
-
each
_ byte (22) -
each
_ char (22) -
each
_ codepoint (22) -
each
_ line (66) - eof (11)
- eof? (11)
-
external
_ encoding (11) - fcntl (11)
- fdatasync (11)
- fileno (11)
- flush (11)
- getbyte (11)
- getc (11)
- gets (33)
-
internal
_ encoding (11) - isatty (11)
- lineno (11)
- lineno= (11)
- pos (11)
- pos= (11)
- pread (7)
- pwrite (7)
- read (11)
- readbyte (11)
- readchar (11)
- readline (33)
- readlines (33)
- reopen (33)
- rewind (11)
- seek (11)
-
set
_ encoding (33) -
set
_ encoding _ by _ bom (5) - stat (11)
- sync (11)
- sysread (11)
- sysseek (11)
- syswrite (11)
- tell (11)
-
to
_ i (11) - tty? (11)
- ungetbyte (11)
- ungetc (11)
- write (11)
検索結果
先頭5件
-
IO
# fileno -> Integer (14102.0) -
ファイル記述子を表す整数を返します。
...ファイル記述子を表す整数を返します。
@raise IOError 既に close されている場合に発生します。
//emlist[例][ruby]{
$stdin.fileno # => 0
$stdout.fileno # => 1
//}......ファイル記述子を表す整数を返します。
@raise IOError 既に close されている場合に発生します。
//emlist[例][ruby]{
$stdin.fileno # => 0
$stdout.fileno # => 1
//}
@see Dir#fileno... -
IO
# to _ i -> Integer (11002.0) -
ファイル記述子を表す整数を返します。
...ファイル記述子を表す整数を返します。
@raise IOError 既に close されている場合に発生します。
//emlist[例][ruby]{
$stdin.fileno # => 0
$stdout.fileno # => 1
//}......ファイル記述子を表す整数を返します。
@raise IOError 既に close されている場合に発生します。
//emlist[例][ruby]{
$stdin.fileno # => 0
$stdout.fileno # => 1
//}
@see Dir#fileno... -
IO
# stat -> File :: Stat (8143.0) -
ファイルのステータスを含む File::Stat オブジェクトを生成して 返します。
...タスを含む File::Stat オブジェクトを生成して
返します。
@raise Errno::EXXX ステータスの読み込みに失敗した場合に発生します。
@raise IOError 既に close されていた場合に発生します。
//emlist[例][ruby]{
IO.write("testfile", "This is line......one\nThis is line two\n")
File.open("testfile") do |f|
s = f.stat
"%o" % s.mode # => "100644"
s.blksize # => 4096
s.atime # => 2018-03-01 23:19:59 +0900
end
//}
@see File#lstat, File.stat, File.lstat... -
IO
# readlines(limit , chomp: false) -> [String] (8032.0) -
データを全て読み込んで、その各行を要素としてもつ配列を返します。 既に EOF に達していれば空配列 [] を返します。
...す。
@raise IOError 自身が読み込み用にオープンされていなければ発生します。
//emlist[例][ruby]{
IO.write("testfile", "line1,\nline2,\nline3,\n")
File.open("testfile") { |f| p f.readlines } # => ["line1,\n", "line2,\n", "line3,\n"]
File.open("testfile") { |f| p f.r......n", "e2,", "\n", "lin", "e3,", "\n"]
File.open("testfile") { |f| p f.readlines(",") } # => ["line1,", "\nline2,", "\nline3,", "\n"]
//}
//emlist[例: rsを取り除く(chomp = true)][ruby]{
IO.write("testfile", "line1,\rline2,\r\nline3,\n")
File.open("testfile") { |f| p f.readlines(chomp: true)......} # => ["line1,\rline2,", "line3,"]
File.open("testfile") { |f| p f.readlines("\r", chomp: true) } # => ["line1,", "line2,", "\nline3,\n"]
//}
@see $/, IO#gets... -
IO
# readlines(rs = $ / , chomp: false) -> [String] (8032.0) -
データを全て読み込んで、その各行を要素としてもつ配列を返します。 既に EOF に達していれば空配列 [] を返します。
...す。
@raise IOError 自身が読み込み用にオープンされていなければ発生します。
//emlist[例][ruby]{
IO.write("testfile", "line1,\nline2,\nline3,\n")
File.open("testfile") { |f| p f.readlines } # => ["line1,\n", "line2,\n", "line3,\n"]
File.open("testfile") { |f| p f.r......n", "e2,", "\n", "lin", "e3,", "\n"]
File.open("testfile") { |f| p f.readlines(",") } # => ["line1,", "\nline2,", "\nline3,", "\n"]
//}
//emlist[例: rsを取り除く(chomp = true)][ruby]{
IO.write("testfile", "line1,\rline2,\r\nline3,\n")
File.open("testfile") { |f| p f.readlines(chomp: true)......} # => ["line1,\rline2,", "line3,"]
File.open("testfile") { |f| p f.readlines("\r", chomp: true) } # => ["line1,", "line2,", "\nline3,\n"]
//}
@see $/, IO#gets... -
IO
# readlines(rs , limit , chomp: false) -> [String] (8032.0) -
データを全て読み込んで、その各行を要素としてもつ配列を返します。 既に EOF に達していれば空配列 [] を返します。
...す。
@raise IOError 自身が読み込み用にオープンされていなければ発生します。
//emlist[例][ruby]{
IO.write("testfile", "line1,\nline2,\nline3,\n")
File.open("testfile") { |f| p f.readlines } # => ["line1,\n", "line2,\n", "line3,\n"]
File.open("testfile") { |f| p f.r......n", "e2,", "\n", "lin", "e3,", "\n"]
File.open("testfile") { |f| p f.readlines(",") } # => ["line1,", "\nline2,", "\nline3,", "\n"]
//}
//emlist[例: rsを取り除く(chomp = true)][ruby]{
IO.write("testfile", "line1,\rline2,\r\nline3,\n")
File.open("testfile") { |f| p f.readlines(chomp: true)......} # => ["line1,\rline2,", "line3,"]
File.open("testfile") { |f| p f.readlines("\r", chomp: true) } # => ["line1,", "line2,", "\nline3,\n"]
//}
@see $/, IO#gets... -
IO
# set _ encoding _ by _ bom -> Encoding | nil (8026.0) -
BOM から IO のエンコーディングを設定します。
...BOM から IO のエンコーディングを設定します。
自身が BOM から始まる場合、BOM を読み進めて外部エンコーディングをセットし、セットしたエンコーディングを返します。
BOM が見つからなかった場合は nil を返します。
自......[例][ruby]{
File.write("bom.txt", "\u{FEFF}abc")
File.open("bom.txt", "rb") do |io|
p io.set_encoding_by_bom #=> #<Encoding:UTF-8>
str = io.read
p str #=> "abc"
p str.encoding #=> #<Encoding:UTF-8>
end
File.write("nobom.txt", "abc")
File.open("nobom.......txt", "rb") do |io|
p io.set_encoding_by_bom #=> nil
end
//}... -
IO
# write(*str) -> Integer (8026.0) -
IOポートに対して str を出力します。str が文字列でなけ れば to_s による文字列化を試みます。 実際に出力できたバイト数を返します。
...
IOポートに対して str を出力します。str が文字列でなけ
れば to_s による文字列化を試みます。
実際に出力できたバイト数を返します。
IO#syswrite を除く全ての出力メソッドは、最終的に
"write" という名のメソッドを呼び出......す。
@raise IOError 自身が書き込み用にオープンされていなければ発生します。
@raise Errno::EXXX 出力に失敗した場合に発生します。
//emlist[例][ruby]{
File.open("textfile", "w+") do |f|
f.write("This is") # => 7
end
File.read("textfile") # => "This is"......//}
//emlist[複数引数の例][ruby]{
File.open("textfile", "w+") do |f|
f.write("This is", " a test\n") # => 15
end
File.read("textfile") # => "This is a test\n"
//}... -
IO
# each(limit , chomp: false) -> Enumerator (8020.0) -
IO の現在位置から 1 行ずつ文字列として読み込み、それを引数として 与えられたブロックを実行します。
...
IO の現在位置から 1 行ずつ文字列として読み込み、それを引数として
与えられたブロックを実行します。
ブロックが与えられなかった場合は、自身から生成した
Enumerator オブジェクトを返します。
テキスト読み込みメソ......り除きます。
@raise IOError 自身が読み込み用にオープンされていなければ発生します。
//emlist[例: 引数なし][ruby]{
IO.write("testfile", "This is line one,\nThis is line two,\nThis is line three,\nAnd so on...")
f = File.new("testfile")
f.each { |line| p "#{f.lin......: 行の区切りに半角カンマ、最大読み取りバイト数に 10 を指定][ruby]{
IO.write("testfile", "This is line one,This is line two,This is line three,And so on...")
f = File.new("testfile")
f.each(",", 10) { |line| p "#{f.lineno}: #{line}" }
# => "0: This is li"
# "1: ne one,"
# "1... -
IO
# each(limit , chomp: false) {|line| . . . } -> self (8020.0) -
IO の現在位置から 1 行ずつ文字列として読み込み、それを引数として 与えられたブロックを実行します。
...
IO の現在位置から 1 行ずつ文字列として読み込み、それを引数として
与えられたブロックを実行します。
ブロックが与えられなかった場合は、自身から生成した
Enumerator オブジェクトを返します。
テキスト読み込みメソ......り除きます。
@raise IOError 自身が読み込み用にオープンされていなければ発生します。
//emlist[例: 引数なし][ruby]{
IO.write("testfile", "This is line one,\nThis is line two,\nThis is line three,\nAnd so on...")
f = File.new("testfile")
f.each { |line| p "#{f.lin......: 行の区切りに半角カンマ、最大読み取りバイト数に 10 を指定][ruby]{
IO.write("testfile", "This is line one,This is line two,This is line three,And so on...")
f = File.new("testfile")
f.each(",", 10) { |line| p "#{f.lineno}: #{line}" }
# => "0: This is li"
# "1: ne one,"
# "1... -
IO
# each(rs = $ / , chomp: false) -> Enumerator (8020.0) -
IO の現在位置から 1 行ずつ文字列として読み込み、それを引数として 与えられたブロックを実行します。
...
IO の現在位置から 1 行ずつ文字列として読み込み、それを引数として
与えられたブロックを実行します。
ブロックが与えられなかった場合は、自身から生成した
Enumerator オブジェクトを返します。
テキスト読み込みメソ......り除きます。
@raise IOError 自身が読み込み用にオープンされていなければ発生します。
//emlist[例: 引数なし][ruby]{
IO.write("testfile", "This is line one,\nThis is line two,\nThis is line three,\nAnd so on...")
f = File.new("testfile")
f.each { |line| p "#{f.lin......: 行の区切りに半角カンマ、最大読み取りバイト数に 10 を指定][ruby]{
IO.write("testfile", "This is line one,This is line two,This is line three,And so on...")
f = File.new("testfile")
f.each(",", 10) { |line| p "#{f.lineno}: #{line}" }
# => "0: This is li"
# "1: ne one,"
# "1... -
IO
# each(rs = $ / , chomp: false) {|line| . . . } -> self (8020.0) -
IO の現在位置から 1 行ずつ文字列として読み込み、それを引数として 与えられたブロックを実行します。
...
IO の現在位置から 1 行ずつ文字列として読み込み、それを引数として
与えられたブロックを実行します。
ブロックが与えられなかった場合は、自身から生成した
Enumerator オブジェクトを返します。
テキスト読み込みメソ......り除きます。
@raise IOError 自身が読み込み用にオープンされていなければ発生します。
//emlist[例: 引数なし][ruby]{
IO.write("testfile", "This is line one,\nThis is line two,\nThis is line three,\nAnd so on...")
f = File.new("testfile")
f.each { |line| p "#{f.lin......: 行の区切りに半角カンマ、最大読み取りバイト数に 10 を指定][ruby]{
IO.write("testfile", "This is line one,This is line two,This is line three,And so on...")
f = File.new("testfile")
f.each(",", 10) { |line| p "#{f.lineno}: #{line}" }
# => "0: This is li"
# "1: ne one,"
# "1...