るりまサーチ

最速Rubyリファレンスマニュアル検索!
304件ヒット [101-200件を表示] (0.032秒)
トップページ > クラス:IO[x] > クエリ:io[x] > クエリ:each[x]

別のキーワード

  1. io popen
  2. io pipe
  3. io each_line
  4. io readlines

ライブラリ

キーワード

検索結果

<< < 1 2 3 4 > >>

IO#each_line(rs, limit, chomp: false) -> Enumerator (15171.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.lineno...
...の区切りに半角カンマ、最大読み取りバイト数に 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: Thi...

IO#each_line(rs, limit, chomp: false) {|line| ... } -> self (15171.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.lineno...
...の区切りに半角カンマ、最大読み取りバイト数に 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: Thi...

IO#each_line(limit) -> Enumerator (15159.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.lineno...
...の区切りに半角カンマ、最大読み取りバイト数に 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: Thi...

IO#each_line(limit) {|line| ... } -> self (15159.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.lineno...
...の区切りに半角カンマ、最大読み取りバイト数に 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: Thi...

IO#each_line(rs = $/) -> Enumerator (15159.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.lineno...
...の区切りに半角カンマ、最大読み取りバイト数に 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: Thi...

絞り込み条件を変える

IO#each_line(rs = $/) {|line| ... } -> self (15159.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.lineno...
...の区切りに半角カンマ、最大読み取りバイト数に 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: Thi...

IO#each_line(rs, limit) -> Enumerator (15159.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.lineno...
...の区切りに半角カンマ、最大読み取りバイト数に 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: Thi...

IO#each_line(rs, limit) {|line| ... } -> self (15159.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.lineno...
...の区切りに半角カンマ、最大読み取りバイト数に 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: Thi...

IO.foreach(path, rs = $/, chomp: false) -> Enumerator (15149.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...
...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...

IO.foreach(path, rs = $/, chomp: false) {|line| ... } -> nil (15149.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...
...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...

絞り込み条件を変える

IO#each_byte -> Enumerator (15143.0)

IO の現在位置から 1 バイトずつ読み込み、それを整数として与え、ブロックを実行します。

...
IO
の現在位置から 1 バイトずつ読み込み、それを整数として与え、ブロックを実行します。

ブロックが与えられなかった場合は、自身から生成した
Enumerator オブジェクトを返します。

バイナリ読み込みメソッドとして動...
...作します。

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

//emlist[例][ruby]{
IO
.write("testfile", "aあ")
File.open("testfile") do |io|
io
.each_byte { |x| p x }
# => 97
# 227
# 129
# 130
end
//}...

IO#each_byte {|ch| ... } -> self (15143.0)

IO の現在位置から 1 バイトずつ読み込み、それを整数として与え、ブロックを実行します。

...
IO
の現在位置から 1 バイトずつ読み込み、それを整数として与え、ブロックを実行します。

ブロックが与えられなかった場合は、自身から生成した
Enumerator オブジェクトを返します。

バイナリ読み込みメソッドとして動...
...作します。

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

//emlist[例][ruby]{
IO
.write("testfile", "aあ")
File.open("testfile") do |io|
io
.each_byte { |x| p x }
# => 97
# 227
# 129
# 130
end
//}...

IO.foreach(path, rs = $/) -> Enumerator (15137.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...
...estfile", "line1,line2,line3")
IO
.foreach("testfile", ",") { |x| puts "GOT #{x}" }
# => GOT line1,
# GOT line2,
# GOT line3
//}


@see $/...

IO.foreach(path, rs = $/) {|line| ... } -> nil (15137.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...
...estfile", "line1,line2,line3")
IO
.foreach("testfile", ",") { |x| puts "GOT #{x}" }
# => GOT line1,
# GOT line2,
# GOT line3
//}


@see $/...

IO#each_codepoint -> Enumerator (15131.0)

IO の各コードポイントに対して繰り返しブロックを呼びだします。

...
IO
の各コードポイントに対して繰り返しブロックを呼びだします。

ブロックの引数にはコードポイントを表す整数が渡されます。

ブロックを省略した場合には、Enumerator を返します。

//emlist[例][ruby]{
IO
.write("testfile", "abcde...
...あ")
File.open("testfile") do |f|
f.each_codepoint { |i| p i }
end
# => 97
# 98
# 99
# 100
# 101
# 12354
//}...

絞り込み条件を変える

IO#each_codepoint {|c| ... } -> self (15131.0)

IO の各コードポイントに対して繰り返しブロックを呼びだします。

...
IO
の各コードポイントに対して繰り返しブロックを呼びだします。

ブロックの引数にはコードポイントを表す整数が渡されます。

ブロックを省略した場合には、Enumerator を返します。

//emlist[例][ruby]{
IO
.write("testfile", "abcde...
...あ")
File.open("testfile") do |f|
f.each_codepoint { |i| p i }
end
# => 97
# 98
# 99
# 100
# 101
# 12354
//}...

IO#each_char -> Enumerator (15109.0)

self に含まれる文字を一文字ずつブロックに渡して評価します。

...ません。

ブロックを省略した場合は各文字について繰り返す Enumerator を返します。

@raise IOError self が読み込み用にオープンされていない場合に発生します。

f = File.new("testfile")
f.each_char {|c| print c, ' ' } #=> #<File:testfile>...
<< < 1 2 3 4 > >>