クラス
- Enumerator (155)
-
Enumerator
:: Chain (6) -
Enumerator
:: Lazy (11) -
Enumerator
:: Yielder (27) - IO (154)
- Object (44)
- OpenStruct (22)
- Pathname (70)
- Prime (44)
-
Prime
:: PseudoPrimeGenerator (44) - StopIteration (11)
- StringIO (94)
- Struct (78)
モジュール
- Enumerable (44)
- Kernel (18)
- ObjectSpace (44)
キーワード
- << (11)
- Enumerator (11)
- Fiber (11)
-
NEWS for Ruby 2
. 0 . 0 (11) -
NEWS for Ruby 2
. 2 . 0 (10) -
NEWS for Ruby 2
. 3 . 0 (9) -
NEWS for Ruby 2
. 4 . 0 (8) -
NEWS for Ruby 2
. 6 . 0 (6) -
NEWS for Ruby 2
. 7 . 0 (5) -
NEWS for Ruby 3
. 0 . 0 (4) -
NEWS for Ruby 3
. 1 . 0 (3) - Ruby用語集 (11)
- Yielder (11)
- ascend (22)
- bytes (14)
- descend (22)
- each (198)
-
each
_ byte (22) -
each
_ char (22) -
each
_ entry (26) -
each
_ line (88) -
each
_ object (44) -
each
_ pair (44) -
each
_ with _ index (44) -
enum
_ for (22) - feed (11)
- filter (12)
- find (22)
- lines (14)
- loop (18)
-
next
_ values (11) - optparse (11)
-
peek
_ values (11) - produce (5)
- result (11)
-
ruby 1
. 9 feature (11) - select (22)
- size (11)
-
to
_ enum (22) -
to
_ proc (5) -
with
_ index (44) -
with
_ object (22) - yield (11)
検索結果
先頭5件
- Prime
. each(upper _ bound = nil , generator = EratosthenesGenerator . new) -> Enumerator - Object
# enum _ for(method = :each , *args) -> Enumerator - Object
# enum _ for(method = :each , *args) {|*args| . . . } -> Enumerator - Object
# to _ enum(method = :each , *args) -> Enumerator - Object
# to _ enum(method = :each , *args) {|*args| . . . } -> Enumerator
-
Prime
. each(upper _ bound = nil , generator = EratosthenesGenerator . new) -> Enumerator (209.0) -
Prime.instance.each と同じです。
...。
@param generator 素数生成器のインスタンスを指定します。
@return ブロックの最後に評価された値を返します。
ブロックが与えられなかった場合は、Enumerator と互換性のある外部イテレータを返します。
@see Prime#each... -
Object
# enum _ for(method = :each , *args) -> Enumerator (166.0) -
Enumerator.new(self, method, *args) を返します。
...
Enumerator.new(self, method, *args) を返します。
ブロックを指定した場合は Enumerator#size がブロックの評価結果を返
します。ブロックパラメータは引数 args です。
@param method メソッド名の文字列かシンボルです。
@param args 呼び出......or(:each_byte)
p(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]
# protects an array from being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}
//emlist[例(ブロックを指定する場合)][ruby]{
module Enumerable
def repeat(n)
raise ArgumentError, "#{n} i......each do |*val|
n.times { yield *val }
end
end
end
%i[hello world].repeat(2) { |w| puts w }
# => 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)
# => #<Enumerator: 1..14:repeat(3)>
enum.first(4) # => [1, 1, 1, 2]
enum.size # => 42
//}
@see Enumerator, Enumerator#size... -
Object
# enum _ for(method = :each , *args) {|*args| . . . } -> Enumerator (166.0) -
Enumerator.new(self, method, *args) を返します。
...
Enumerator.new(self, method, *args) を返します。
ブロックを指定した場合は Enumerator#size がブロックの評価結果を返
します。ブロックパラメータは引数 args です。
@param method メソッド名の文字列かシンボルです。
@param args 呼び出......or(:each_byte)
p(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]
# protects an array from being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}
//emlist[例(ブロックを指定する場合)][ruby]{
module Enumerable
def repeat(n)
raise ArgumentError, "#{n} i......each do |*val|
n.times { yield *val }
end
end
end
%i[hello world].repeat(2) { |w| puts w }
# => 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)
# => #<Enumerator: 1..14:repeat(3)>
enum.first(4) # => [1, 1, 1, 2]
enum.size # => 42
//}
@see Enumerator, Enumerator#size... -
Object
# to _ enum(method = :each , *args) -> Enumerator (166.0) -
Enumerator.new(self, method, *args) を返します。
...
Enumerator.new(self, method, *args) を返します。
ブロックを指定した場合は Enumerator#size がブロックの評価結果を返
します。ブロックパラメータは引数 args です。
@param method メソッド名の文字列かシンボルです。
@param args 呼び出......or(:each_byte)
p(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]
# protects an array from being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}
//emlist[例(ブロックを指定する場合)][ruby]{
module Enumerable
def repeat(n)
raise ArgumentError, "#{n} i......each do |*val|
n.times { yield *val }
end
end
end
%i[hello world].repeat(2) { |w| puts w }
# => 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)
# => #<Enumerator: 1..14:repeat(3)>
enum.first(4) # => [1, 1, 1, 2]
enum.size # => 42
//}
@see Enumerator, Enumerator#size... -
Object
# to _ enum(method = :each , *args) {|*args| . . . } -> Enumerator (166.0) -
Enumerator.new(self, method, *args) を返します。
...
Enumerator.new(self, method, *args) を返します。
ブロックを指定した場合は Enumerator#size がブロックの評価結果を返
します。ブロックパラメータは引数 args です。
@param method メソッド名の文字列かシンボルです。
@param args 呼び出......or(:each_byte)
p(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]
# protects an array from being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}
//emlist[例(ブロックを指定する場合)][ruby]{
module Enumerable
def repeat(n)
raise ArgumentError, "#{n} i......each do |*val|
n.times { yield *val }
end
end
end
%i[hello world].repeat(2) { |w| puts w }
# => 'hello', 'hello', 'world', 'world'
enum = (1..14).repeat(3)
# => #<Enumerator: 1..14:repeat(3)>
enum.first(4) # => [1, 1, 1, 2]
enum.size # => 42
//}
@see Enumerator, Enumerator#size... -
Kernel
. # loop -> Enumerator (135.0) -
(中断されない限り)永遠にブロックの評価を繰り返します。 ブロックが指定されなければ、代わりに Enumerator を返します。
...れば、代わりに Enumerator を返します。
//emlist[例][ruby]{
loop do
print "Input: "
line = gets
break if !line or line =~ /^qQ/
# ...
end
//}
与えられたブロック内で StopIteration を Kernel.#raise すると
ループを終了して Enumerator が最後に返した......値を返します。
ループを終了させる場合、通常は break を使用してください。
//emlist[例][ruby]{
enum = Enumerator.new { |y|
y << "one"
y << "two"
:ok
}
result = loop {
puts enum.next
} # => :ok
//}
@return break の引数など、ループ脱出時の値を... -
ObjectSpace
. # each _ object -> Enumerator (132.0) -
指定された klass と Object#kind_of? の関係にある全ての オブジェクトに対して繰り返します。引数が省略された時には全てのオブ ジェクトに対して繰り返します。 繰り返した数を返します。
...のオブ
ジェクトに対して繰り返します。
繰り返した数を返します。
ブロックが与えられなかった場合は、
Enumerator オブジェクトを返します。
次のクラスのオブジェクトについては繰り返しません
* Fixnum
* Symbol
* TrueClas......す。
@param klass クラスかモジュールを指定します。
//emlist[例: ブロックなし][ruby]{
p ObjectSpace.each_object
# => #<Enumerator: ObjectSpace:each_object(false)>
//}
//emlist[例: 全てのオブジェクトを扱う][ruby]{
ObjectSpace.each_object.take(5).each { |x| p x......ss_names"
# => "@corrections"
# => Total count: 9938
//}
//emlist[例: 任意のクラスを扱う][ruby]{
Person = Struct.new(:name)
s1 = Person.new("tanaka")
s2 = Person.new("sato")
count = ObjectSpace.each_object(Person) { |x| p x }
puts "Total count: #{count}"
# => #<struct Person name="sato"... -
ObjectSpace
. # each _ object(klass) -> Enumerator (132.0) -
指定された klass と Object#kind_of? の関係にある全ての オブジェクトに対して繰り返します。引数が省略された時には全てのオブ ジェクトに対して繰り返します。 繰り返した数を返します。
...のオブ
ジェクトに対して繰り返します。
繰り返した数を返します。
ブロックが与えられなかった場合は、
Enumerator オブジェクトを返します。
次のクラスのオブジェクトについては繰り返しません
* Fixnum
* Symbol
* TrueClas......す。
@param klass クラスかモジュールを指定します。
//emlist[例: ブロックなし][ruby]{
p ObjectSpace.each_object
# => #<Enumerator: ObjectSpace:each_object(false)>
//}
//emlist[例: 全てのオブジェクトを扱う][ruby]{
ObjectSpace.each_object.take(5).each { |x| p x......ss_names"
# => "@corrections"
# => Total count: 9938
//}
//emlist[例: 任意のクラスを扱う][ruby]{
Person = Struct.new(:name)
s1 = Person.new("tanaka")
s2 = Person.new("sato")
count = ObjectSpace.each_object(Person) { |x| p x }
puts "Total count: #{count}"
# => #<struct Person name="sato"... -
IO
# each(limit , chomp: false) -> Enumerator (130.0) -
IO の現在位置から 1 行ずつ文字列として読み込み、それを引数として 与えられたブロックを実行します。
...を引数として
与えられたブロックを実行します。
ブロックが与えられなかった場合は、自身から生成した
Enumerator オブジェクトを返します。
テキスト読み込みメソッドとして動作します。
limit で最大読み込みバイト数......す。
//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}: #{line}" }
# => "1: This is line one,\n"
# "2: This is line two,\n"
# "3: This is line three,\n"
# "4: A......読み取りバイト数に 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 l... -
IO
# each(rs = $ / , chomp: false) -> Enumerator (130.0) -
IO の現在位置から 1 行ずつ文字列として読み込み、それを引数として 与えられたブロックを実行します。
...を引数として
与えられたブロックを実行します。
ブロックが与えられなかった場合は、自身から生成した
Enumerator オブジェクトを返します。
テキスト読み込みメソッドとして動作します。
limit で最大読み込みバイト数......す。
//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}: #{line}" }
# => "1: This is line one,\n"
# "2: This is line two,\n"
# "3: This is line three,\n"
# "4: A......読み取りバイト数に 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 l...