種類
- インスタンスメソッド (3506)
- 特異メソッド (391)
- 文書 (88)
- モジュール関数 (60)
- クラス (50)
ライブラリ
クラス
-
ARGF
. class (138) - Addrinfo (24)
- Array (398)
- CSV (12)
- Date (60)
- Dir (59)
- Enumerator (212)
-
Enumerator
:: ArithmeticSequence (98) -
Enumerator
:: Chain (42) -
Enumerator
:: Lazy (429) -
Enumerator
:: Yielder (30) -
Etc
:: Group (12) -
Etc
:: Passwd (12) -
Gem
:: SourceIndex (12) - Hash (246)
- IO (162)
- Integer (72)
- Matrix (154)
- Numeric (93)
- Object (78)
- OpenStruct (24)
- Pathname (126)
- Prime (48)
-
Prime
:: PseudoPrimeGenerator (84) -
Psych
:: Nodes :: Node (12) -
REXML
:: Parent (48) - Range (59)
- StopIteration (12)
- String (112)
- StringIO (88)
- Struct (43)
- Vector (160)
-
Zlib
:: GzipReader (36)
モジュール
- Enumerable (478)
- Find (12)
- Kernel (24)
- ObjectSpace (24)
- TSort (66)
オブジェクト
- ENV (134)
-
Readline
:: HISTORY (24)
キーワード
- % (14)
- + (7)
- << (12)
- == (7)
- ArithmeticSequence (7)
- Chain (7)
- Lazy (12)
-
NEWS for Ruby 2
. 0 . 0 (12) -
NEWS for Ruby 2
. 2 . 0 (11) -
NEWS for Ruby 2
. 3 . 0 (10) -
NEWS for Ruby 2
. 4 . 0 (9) -
NEWS for Ruby 2
. 6 . 0 (7) -
NEWS for Ruby 2
. 7 . 0 (6) -
NEWS for Ruby 3
. 0 . 0 (5) -
NEWS for Ruby 3
. 1 . 0 (4) - Ruby用語集 (12)
- Yielder (12)
- ascend (24)
- begin (7)
- bsearch (24)
-
bsearch
_ index (10) - bytes (21)
- chain (7)
- chars (21)
- chunk (36)
-
chunk
_ while (21) - codepoints (21)
- collect (86)
- collect! (33)
- collect2 (24)
-
collect
_ concat (24) - combination (24)
- combine (8)
- compact (4)
- cycle (36)
-
delete
_ if (60) - descend (24)
- detect (12)
- downto (48)
- drop (12)
-
drop
_ while (36) - each (412)
- each2 (24)
-
each
_ byte (72) -
each
_ char (48) -
each
_ child (59) -
each
_ codepoint (60) -
each
_ cons (12) -
each
_ entry (18) -
each
_ grapheme _ cluster (16) -
each
_ index (24) -
each
_ key (24) -
each
_ line (132) -
each
_ object (24) -
each
_ pair (60) -
each
_ prime (12) -
each
_ slice (12) -
each
_ strongly _ connected _ component (22) -
each
_ strongly _ connected _ component _ from (22) -
each
_ value (24) -
each
_ with _ index (48) -
each
_ with _ object (12) - eager (6)
- end (7)
-
enum
_ for (48) -
exclude
_ end? (7) - feed (12)
- filter (42)
- filter! (21)
-
filter
_ map (12) - find (48)
-
find
_ all (24) -
find
_ index (60) - first (14)
-
flat
_ map (24) - force (12)
- foreach (72)
- grep (12)
-
grep
_ v (10) -
group
_ by (12) - gsub (24)
- gsub! (12)
- hash (7)
- index (48)
- inspect (14)
-
keep
_ if (36) - last (14)
- lazy (24)
- lines (49)
- loop (12)
- map (86)
- map! (33)
- map2 (12)
-
max
_ by (48) -
min
_ by (24) -
minmax
_ by (12) - new (38)
- next (12)
-
next
_ values (12) - partition (12)
- peek (12)
-
peek
_ values (12) - permutation (24)
- produce (6)
- reject (72)
- reject! (48)
-
repeated
_ combination (24) -
repeated
_ permutation (24) - result (12)
-
reverse
_ each (26) - rewind (31)
- rindex (12)
-
ruby 1
. 9 feature (12) - select (72)
- select! (36)
- size (26)
-
slice
_ after (46) -
slice
_ before (60) -
slice
_ when (23) -
sort
_ by (12) -
sort
_ by! (12) - step (131)
- take (12)
-
take
_ while (48) - then (14)
- times (12)
-
to
_ enum (48) -
to
_ proc (6) -
transform
_ keys (20) -
transform
_ keys! (20) -
transform
_ values (18) -
transform
_ values! (18) -
tsort
_ each (22) - uniq (18)
- upto (48)
-
with
_ index (60) -
with
_ object (48) - yield (12)
-
yield
_ self (16) - zip (24)
検索結果
先頭5件
-
Enumerator
# each -> self (24049.0) -
生成時のパラメータに従ってブロックを繰り返します。 *args を渡した場合は、生成時のパラメータ内引数末尾へ *args を追加した状態で繰り返します。 ブロック付きで呼び出された場合は、 生成時に指定したイテレータの戻り値をそのまま返します。
...戻り値をそのまま返します。
@param args 末尾へ追加する引数
//emlist[例1][ruby]{
str = "Yet Another Ruby Hacker"
enum = Enumerator.new {|y| str.scan(/\w+/) {|w| y << w }}
enum.each {|word| p word } # => "Yet"
# "Another"......orld!".to_enum(:scan, /\w+/).to_a # => ["Hello", "world"]
"Hello, world!".to_enum(:scan).each(/\w+/).to_a # => ["Hello", "world"]
obj = Object.new
def obj.each_arg(a, b=:b, *rest)
yield a
yield b
yield rest
:method_returned
end
enum = obj.to_enum :each_arg, :a, :x
enum.each.to_a......# => [:a, :x, []]
enum.each.equal?(enum) # => true
enum.each { |elm| elm } # => :method_returned
enum.each(:y, :z).to_a # => [:a, :x, [:y, :z]]
enum.each(:y, :z).equal?(enum) # => false
enum.each(:y, :z) { |elm| elm } # => :method_returned
//}... -
Enumerator
# each { . . . } -> object (24049.0) -
生成時のパラメータに従ってブロックを繰り返します。 *args を渡した場合は、生成時のパラメータ内引数末尾へ *args を追加した状態で繰り返します。 ブロック付きで呼び出された場合は、 生成時に指定したイテレータの戻り値をそのまま返します。
...戻り値をそのまま返します。
@param args 末尾へ追加する引数
//emlist[例1][ruby]{
str = "Yet Another Ruby Hacker"
enum = Enumerator.new {|y| str.scan(/\w+/) {|w| y << w }}
enum.each {|word| p word } # => "Yet"
# "Another"......orld!".to_enum(:scan, /\w+/).to_a # => ["Hello", "world"]
"Hello, world!".to_enum(:scan).each(/\w+/).to_a # => ["Hello", "world"]
obj = Object.new
def obj.each_arg(a, b=:b, *rest)
yield a
yield b
yield rest
:method_returned
end
enum = obj.to_enum :each_arg, :a, :x
enum.each.to_a......# => [:a, :x, []]
enum.each.equal?(enum) # => true
enum.each { |elm| elm } # => :method_returned
enum.each(:y, :z).to_a # => [:a, :x, [:y, :z]]
enum.each(:y, :z).equal?(enum) # => false
enum.each(:y, :z) { |elm| elm } # => :method_returned
//}... -
Enumerator
# each(*args) { . . . } -> object (24049.0) -
生成時のパラメータに従ってブロックを繰り返します。 *args を渡した場合は、生成時のパラメータ内引数末尾へ *args を追加した状態で繰り返します。 ブロック付きで呼び出された場合は、 生成時に指定したイテレータの戻り値をそのまま返します。
...戻り値をそのまま返します。
@param args 末尾へ追加する引数
//emlist[例1][ruby]{
str = "Yet Another Ruby Hacker"
enum = Enumerator.new {|y| str.scan(/\w+/) {|w| y << w }}
enum.each {|word| p word } # => "Yet"
# "Another"......orld!".to_enum(:scan, /\w+/).to_a # => ["Hello", "world"]
"Hello, world!".to_enum(:scan).each(/\w+/).to_a # => ["Hello", "world"]
obj = Object.new
def obj.each_arg(a, b=:b, *rest)
yield a
yield b
yield rest
:method_returned
end
enum = obj.to_enum :each_arg, :a, :x
enum.each.to_a......# => [:a, :x, []]
enum.each.equal?(enum) # => true
enum.each { |elm| elm } # => :method_returned
enum.each(:y, :z).to_a # => [:a, :x, [:y, :z]]
enum.each(:y, :z).equal?(enum) # => false
enum.each(:y, :z) { |elm| elm } # => :method_returned
//}... -
Enumerator
# with _ object(obj) {|(*args) , memo _ obj| . . . } -> object (24043.0) -
繰り返しの各要素に obj を添えてブロックを繰り返し、obj を返り値として返します。
...を実行し、
最後に obj を返す Enumerator を返します。
//emlist[例][ruby]{
# 0,1,2 と呼びだす enumeratorを作る
to_three = Enumerator.new do |y|
3.times do |x|
y << x
end
end
to_three_with_string = to_three.with_object("foo")
to_three_with_string.each do |x,string|... -
Enumerator
# next _ values -> Array (24036.0) -
「次」のオブジェクトを配列で返します。
...「次」のオブジェクトを配列で返します。
Enumerator#next とほぼ同様の挙動をします。終端まで到達した場合は
StopIteration 例外を発生させます。
このメソッドは、
yield
と
yield nil
を区別するために使えます。
next メソッ......[ruby]{
o = Object.new
def o.each
yield
yield 1
yield 1, 2
yield nil
yield [1, 2]
end
e = o.to_enum
p e.next_values
p e.next_values
p e.next_values
p e.next_values
p e.next_values
e = o.to_enum
p e.next
p e.next
p e.next
p e.next
p e.next
## yield args next_values next
# yield......[1] 1
# yield 1, 2 [1, 2] [1, 2]
# yield nil [nil] nil
# yield [1, 2] [[1, 2]] [1, 2]
//}
@raise StopIteration 列挙状態が既に最後へ到達しているとき
@see Enumerator#next, Enumerator#peek, Enumerator#peek_values... -
Enumerator
# peek -> object (24030.0) -
「次」のオブジェクトを返しますが、列挙状態を変化させません。
...状態を変化させません。
Enumerator#next のように
現在までの列挙状態に応じて「次」のオブジェクトを返しますが、
next と異なり列挙状態を変更しません。
列挙が既に最後へ到達している場合は、StopIteration 例外を発生しま......,3]
e = a.to_enum
p e.next #=> 1
p e.peek #=> 2
p e.peek #=> 2
p e.peek #=> 2
p e.next #=> 2
p e.next #=> 3
p e.next #raises StopIteration
//}
@raise StopIteration 列挙状態が既に最後へ到達しているとき
@see Enumerator#next, Enumerator#next_values, Enumerator#peek_valu... -
Enumerator
# feed(obj) -> nil (24028.0) -
Enumerator 内部の yield が返す値を設定します。
...
Enumerator 内部の yield が返す値を設定します。
これで値を設定しなかった場合は yield は nil を返します。
この値は内部で yield された時点でクリアされます。
//emlist[例][ruby]{
# (1), (2), ... (10) の順に実行される
o = Object.new
def......cks
p x # not reached w/o another e.next
end
e = o.to_enum
e.next # (1)
e.feed "foo" # (3)
e.next # (4)
e.next # (7)
# (10)
//}
@param obj Enumerator 内部の yield が返す値
@raise TypeError すでに値をこ... -
Enumerator
# size -> Integer | Float :: INFINITY | nil (24018.0) -
self の要素数を返します。
...Float::INFINITY を返します。
Enumerator.new に Proc オブジェクトを指定していた場合はその
実行結果を返します。呼び出した時に要素数が不明であった場合は nil を返し
ます。
//emlist[例][ruby]{
(1..100).to_a.permutation(4).size # => 94109400......loop.size # => Float::INFINITY
(1..100).drop_while.size # => nil
//}
@see Enumerator.new... -
Enumerator
# with _ index(offset = 0) {|(*args) , idx| . . . } -> object (24013.0) -
生成時のパラメータに従って、要素にインデックスを添えて繰り返します。 インデックスは offset から始まります。
...ブロックを指定した場合の戻り値は生成時に指定したレシーバ自身です。
//emlist[例][ruby]{
str = "xyz"
enum = Enumerator.new {|y| str.each_byte {|b| y << b }}
enum.with_index {|byte, idx| p [byte, idx] }
# => [120, 0]
# [121, 1]
# [122, 2]
require......ータに従って、要素にインデックスを添えてブロックを繰り返します。
インデックスは 0 から始まります。
Enumerator#with_index は offset 引数を受け取りますが、
each_with_index は受け取りません (引数はイテレータメソッドにその...