るりまサーチ

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

別のキーワード

  1. _builtin each
  2. _builtin each_line
  3. prime each
  4. each
  5. tsort tsort_each

クラス

モジュール

オブジェクト

キーワード

検索結果

<< < 1 2 3 4 ... > >>

IO#each(rs, limit, chomp: false) -> Enumerator (18244.0)

IO の現在位置から 1 行ずつ文字列として読み込み、それを引数として 与えられたブロックを実行します。

...を引数として
与えられたブロックを実行します。

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

テキスト読み込みメソッドとして動作します。

limit で最大読み込みバイト数...
...: 引数なし][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}: #{line}" }
# => "1: This is line one,\n"
# "2: This is line two,\n"
# "3: This is line three,\n"
# "4: And so on..."
//}
//e...
...ト数に 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: This is li"
# "2: ne two,"
# "2: This is li"
# "3: ne three,...

ARGF.class#each(rs = $/) -> Enumerator (18238.0)

ARGFの現在位置から 1 行ずつ文字列として読み込み、それを引数として与えら れたブロックを実行します。

...て読み込み、それを引数として与えら
れたブロックを実行します。

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

このメソッドはスクリプトに指定した引数(Object::ARGV を参照) をファ...
...フモード)。

@param limit 各行の最大の読み込みバイト数

例: ARGFの各ファイル名(最初に1回のみ)、行番号、内容を表示

ARGF.each_line do |line|
puts ARGF.filename if ARGF.lineno == 1
puts "#{ARGF.lineno}: #{line}"
end

@see IO#each, IO#each_line...

ARGF.class#each(rs = $/, limit) -> Enumerator (18238.0)

ARGFの現在位置から 1 行ずつ文字列として読み込み、それを引数として与えら れたブロックを実行します。

...て読み込み、それを引数として与えら
れたブロックを実行します。

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

このメソッドはスクリプトに指定した引数(Object::ARGV を参照) をファ...
...フモード)。

@param limit 各行の最大の読み込みバイト数

例: ARGFの各ファイル名(最初に1回のみ)、行番号、内容を表示

ARGF.each_line do |line|
puts ARGF.filename if ARGF.lineno == 1
puts "#{ARGF.lineno}: #{line}"
end

@see IO#each, IO#each_line...

IO#each(limit) -> Enumerator (18238.0)

IO の現在位置から 1 行ずつ文字列として読み込み、それを引数として 与えられたブロックを実行します。

...を引数として
与えられたブロックを実行します。

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

テキスト読み込みメソッドとして動作します。

limit で最大読み込みバイト数...
...: 引数なし][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}: #{line}" }
# => "1: This is line one,\n"
# "2: This is line two,\n"
# "3: This is line three,\n"
# "4: And so on..."
//}
//e...
...ト数に 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: This is li"
# "2: ne two,"
# "2: This is li"
# "3: ne three,...

IO#each(rs = $/) -> Enumerator (18238.0)

IO の現在位置から 1 行ずつ文字列として読み込み、それを引数として 与えられたブロックを実行します。

...を引数として
与えられたブロックを実行します。

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

テキスト読み込みメソッドとして動作します。

limit で最大読み込みバイト数...
...: 引数なし][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}: #{line}" }
# => "1: This is line one,\n"
# "2: This is line two,\n"
# "3: This is line three,\n"
# "4: And so on..."
//}
//e...
...ト数に 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: This is li"
# "2: ne two,"
# "2: This is li"
# "3: ne three,...

絞り込み条件を変える

IO#each(rs, limit) -> Enumerator (18238.0)

IO の現在位置から 1 行ずつ文字列として読み込み、それを引数として 与えられたブロックを実行します。

...を引数として
与えられたブロックを実行します。

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

テキスト読み込みメソッドとして動作します。

limit で最大読み込みバイト数...
...: 引数なし][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}: #{line}" }
# => "1: This is line one,\n"
# "2: This is line two,\n"
# "3: This is line three,\n"
# "4: And so on..."
//}
//e...
...ト数に 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: This is li"
# "2: ne two,"
# "2: This is li"
# "3: ne three,...

Array#each -> Enumerator (18235.0)

各要素に対してブロックを評価します。

...してブロックを評価します。

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

//emlist[例][ruby]{
[1, 2, 3].each do |i|
puts i
end
#=> 1
# 2
# 3
//}


@see Array#each_index, Array#reverse_each...

Dir#each -> Enumerator (18223.0)

ディレクトリの各エントリを表す文字列を引数として、ブロックを評価します。

...場合、各エントリを文字列として保持する
Enumerator

オブジェクトを返します。

@raise IOError 既に自身が close している場合に発生します。

//emlist[例][ruby]{
Dir.open('.').each{|f|
p f
}
#=> "."
# ".."
# "bar"
# "foo"
//}

@see Dir#each_child...

Range#each -> Enumerator (18223.0)

範囲内の要素に対して繰り返します。

...each は各要素の succ メソッドを使用してイテレーションするようになりました。

@raise TypeError succ メソッドを持たないクラスの範囲オブジェクトに対してこのメソッドを呼んだ場合に発生します。


//emlist[例][ruby]{
(10..15).each...
...{|n| print n, ' ' }
# prints: 10 11 12 13 14 15

(2.5..5).each {|n| print n, ' ' }
# raises: TypeError: can't iterate from Float
//}...

Dir#each -> Enumerator (18217.0)

ディレクトリの各エントリを表す文字列を引数として、ブロックを評価します。

...えられなかった場合、各エントリを文字列として保持する
Enumerator

オブジェクトを返します。

@raise IOError 既に自身が close している場合に発生します。

//emlist[例][ruby]{
Dir.open('.').each{|f|
p f
}
#=> "."
# ".."
# "bar"
# "foo"
//}...

絞り込み条件を変える

ENV.each -> Enumerator (18214.0)

key と value を引数としてブロックを評価します。

...key と value を引数としてブロックを評価します。

//emlist[][ruby]{
ENV['FOO'] = 'bar'
ENV.each do |key, value|
p "value is #{value}" if key == 'FOO' # => "value is bar"
end
# => ENV
//}...

Struct#each -> Enumerator (18211.0)

構造体の各メンバに対して繰り返します。

...ct.new は Struct の下位クラスを作成する点に
注意してください。

//emlist[例][ruby]{
Customer = Struct.new(:name, :address, :zip)
joe = Customer.new("Joe Smith", "123 Maple, Anytown NC", 12345)
joe.each {|x| puts(x) }

# => Joe Smith
# 123 Maple, Anytown NC
# 12345
//}...

Hash#each {|key, value| ... } -> self (18168.0)

ハッシュのキーと値を引数としてブロックを評価します。

...場合 Enumerator を返します。

each
_pair は each のエイリアスです。

//emlist[例][ruby]{
{:a=>1, :b=>2}.each {|a| p a}
#=> [:a, 1]
# [:b, 2]

{:a=>1, :b=>2}.each {|k, v| p [k, v]}
#=> [:a, 1]
# [:b, 2]

p({:a=>1, :b=>2}.each_pair) # => #<Enumerator: {:a=>1, :b=>2}:each_pair>
/...
.../}

@see Hash#each_key,Hash#each_value...
<< < 1 2 3 4 ... > >>