ライブラリ
クラス
-
ARGF
. class (226) - Addrinfo (24)
- Array (569)
- CSV (24)
- Date (48)
- Dir (99)
- Enumerator (212)
-
Enumerator
:: ArithmeticSequence (98) -
Enumerator
:: Chain (42) -
Enumerator
:: Lazy (429) -
Enumerator
:: Yielder (30) -
Etc
:: Group (24) -
Etc
:: Passwd (24) -
Gem
:: SourceIndex (24) - Hash (241)
- IO (286)
- Integer (96)
- Matrix (200)
- Numeric (93)
- Object (77)
- OpenStruct (24)
- Pathname (126)
- Prime (48)
-
Prime
:: PseudoPrimeGenerator (84) -
Psych
:: Nodes :: Node (24) -
REXML
:: Parent (96) - Range (97)
- StopIteration (12)
- String (208)
- StringIO (176)
- Struct (43)
- Vector (88)
-
Zlib
:: GzipReader (72)
モジュール
- Enumerable (789)
- Find (24)
- Kernel (60)
- ObjectSpace (48)
- TSort (132)
オブジェクト
- ENV (268)
-
Readline
:: HISTORY (24)
キーワード
- % (14)
- + (7)
- << (12)
- == (7)
- ArithmeticSequence (7)
- Chain (7)
- Enumerable (12)
- Fiber (12)
- 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 (48)
-
bsearch
_ index (20) - build (24)
- bytes (28)
- chain (7)
- chars (28)
- chunk (36)
-
chunk
_ while (21) - codepoints (42)
- collect (84)
- collect! (40)
- collect2 (12)
-
collect
_ concat (36) - combination (24)
- combine (16)
- compact (4)
- cycle (48)
-
delete
_ if (72) - descend (24)
- detect (24)
- downto (48)
- drop (12)
-
drop
_ while (60) - each (556)
- each2 (12)
-
each
_ byte (96) -
each
_ char (84) -
each
_ child (87) -
each
_ codepoint (96) -
each
_ cons (24) -
each
_ entry (30) -
each
_ grapheme _ cluster (16) -
each
_ index (48) -
each
_ key (36) -
each
_ line (216) -
each
_ object (48) -
each
_ pair (72) -
each
_ prime (24) -
each
_ slice (24) -
each
_ strongly _ connected _ component (44) -
each
_ strongly _ connected _ component _ from (44) -
each
_ value (36) -
each
_ with _ index (72) -
each
_ with _ object (24) - eager (6)
- end (7)
-
enum
_ for (48) -
exclude
_ end? (7) - feed (12)
- filter (56)
- filter! (42)
-
filter
_ map (18) - find (72)
-
find
_ all (36) -
find
_ index (108) - first (14)
-
flat
_ map (36) - force (12)
- foreach (120)
- grep (12)
-
grep
_ v (10) -
group
_ by (24) - gsub (84)
- gsub! (48)
- hash (7)
- index (72)
- inspect (14)
-
keep
_ if (48) - last (14)
- lazy (24)
- lines (98)
- loop (24)
- map (84)
- map! (40)
-
max
_ by (48) -
min
_ by (48) -
minmax
_ by (24) - new (38)
- next (12)
-
next
_ values (12) - partition (24)
- peek (12)
-
peek
_ values (12) - permutation (24)
- produce (6)
- reject (84)
- reject! (72)
-
repeated
_ combination (24) -
repeated
_ permutation (24) - result (12)
-
reverse
_ each (40) - rewind (31)
- rindex (36)
-
ruby 1
. 9 feature (12) - select (96)
- select! (72)
- size (26)
-
slice
_ after (46) -
slice
_ before (60) -
slice
_ when (23) -
sort
_ by (24) -
sort
_ by! (12) - step (143)
- take (12)
-
take
_ while (72) - then (14)
- times (24)
-
to
_ enum (48) -
to
_ proc (6) -
transform
_ keys (20) -
transform
_ keys! (20) -
transform
_ values (18) -
transform
_ values! (18) -
tsort
_ each (44) - uniq (18)
- upto (36)
-
with
_ index (60) -
with
_ object (48) - yield (12)
-
yield
_ self (15) - zip (24)
検索結果
先頭5件
-
Enumerator
# feed(obj) -> nil (24122.0) -
Enumerator 内部の yield が返す値を設定します。
...
Enumerator 内部の yield が返す値を設定します。
これで値を設定しなかった場合は yield は nil を返します。
この値は内部で yield された時点でクリアされます。
//emlist[例][ruby]{
# (1), (2), ... (10) の順に実行される
o = Object.new
def......# (8) => nil
x = yield # (9) blocks
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... -
Enumerator
# size -> Integer | Float :: INFINITY | nil (24112.0) -
self の要素数を返します。
...合は Float::INFINITY を返します。
Enumerator.new に Proc オブジェクトを指定していた場合はその
実行結果を返します。呼び出した時に要素数が不明であった場合は nil を返し
ます。
//emlist[例][ruby]{
(1..100).to_a.permutation(4).size # => 941......09400
loop.size # => Float::INFINITY
(1..100).drop_while.size # => nil
//}
@see Enumerator.new... -
Enumerator
# peek _ values -> Array (24052.0) -
Enumerator#next_values のように「次」のオブジェクトを 配列で返しますが、列挙状態を変化させません。
...
Enumerator#next_values のように「次」のオブジェクトを
配列で返しますが、列挙状態を変化させません。
Enumerator#next, Enumerator#next_values のように
現在までの列挙状態に応じて「次」のオブジェクトを返しますが、
next と異なり......StopIteration 例外を発生します。
このメソッドは Enumerator#next_values と同様
yield
と
yield nil
を区別するために使えます。
//emlist[例][ruby]{
o = Object.new
def o.each
yield
yield 1
yield 1, 2
end
e = o.to_enum
p e.peek_values #=> []
e.next
p e.peek......_values #=> [1]
p e.peek_values #=> [1]
e.next
p e.peek_values #=> [1, 2]
e.next
p e.peek_values # raises StopIteration
//}
@raise StopIteration 列挙状態が既に最後へ到達しているとき
@see Enumerator#next, Enumerator#next_values, Enumerator#peek_values... -
Enumerator
# peek -> object (24024.0) -
「次」のオブジェクトを返しますが、列挙状態を変化させません。
...を変化させません。
Enumerator#next のように
現在までの列挙状態に応じて「次」のオブジェクトを返しますが、
next と異なり列挙状態を変更しません。
列挙が既に最後へ到達している場合は、StopIteration 例外を発生します。......]
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_values... -
Enumerator
# with _ object(obj) {|(*args) , memo _ obj| . . . } -> object (24019.0) -
繰り返しの各要素に 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|
puts "#{string}: #{x}"
end
# =>......foo:0
# => foo:1
# => foo:2
//}
@param obj 繰り返しの各要素に添えて渡されるオブジェクト
@see Enumerable#each_with_object... -
Enumerator
# each -> self (24007.0) -
生成時のパラメータに従ってブロックを繰り返します。 *args を渡した場合は、生成時のパラメータ内引数末尾へ *args を追加した状態で繰り返します。 ブロック付きで呼び出された場合は、 生成時に指定したイテレータの戻り値をそのまま返します。
...nother Ruby Hacker"
enum = Enumerator.new {|y| str.scan(/\w+/) {|w| y << w }}
enum.each {|word| p word } # => "Yet"
# "Another"
# "Ruby"
# "Hacker"
str.scan......# "Another"
# "Ruby"
# "Hacker"
//}
//emlist[例2][ruby]{
"Hello, world!".scan(/\w+/) # => ["Hello", "world"]
"Hello, world!".to_enum(:scan, /\w+/).to_a # => ["Hel......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.... -
Enumerator
# each { . . . } -> object (24007.0) -
生成時のパラメータに従ってブロックを繰り返します。 *args を渡した場合は、生成時のパラメータ内引数末尾へ *args を追加した状態で繰り返します。 ブロック付きで呼び出された場合は、 生成時に指定したイテレータの戻り値をそのまま返します。
...nother Ruby Hacker"
enum = Enumerator.new {|y| str.scan(/\w+/) {|w| y << w }}
enum.each {|word| p word } # => "Yet"
# "Another"
# "Ruby"
# "Hacker"
str.scan......# "Another"
# "Ruby"
# "Hacker"
//}
//emlist[例2][ruby]{
"Hello, world!".scan(/\w+/) # => ["Hello", "world"]
"Hello, world!".to_enum(:scan, /\w+/).to_a # => ["Hel......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.... -
Enumerator
# each(*args) { . . . } -> object (24007.0) -
生成時のパラメータに従ってブロックを繰り返します。 *args を渡した場合は、生成時のパラメータ内引数末尾へ *args を追加した状態で繰り返します。 ブロック付きで呼び出された場合は、 生成時に指定したイテレータの戻り値をそのまま返します。
...nother Ruby Hacker"
enum = Enumerator.new {|y| str.scan(/\w+/) {|w| y << w }}
enum.each {|word| p word } # => "Yet"
# "Another"
# "Ruby"
# "Hacker"
str.scan......# "Another"
# "Ruby"
# "Hacker"
//}
//emlist[例2][ruby]{
"Hello, world!".scan(/\w+/) # => ["Hello", "world"]
"Hello, world!".to_enum(:scan, /\w+/).to_a # => ["Hel......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.... -
ruby 1
. 9 feature (23018.0) -
ruby 1.9 feature ruby version 1.9.0 は開発版です。 以下にあげる機能は将来削除されたり互換性のない仕様変更がなされるかもしれません。 1.9.1 以降は安定版です。 バグ修正がメインになります。
...ruby 1.9 feature
ruby version 1.9.0 は開発版です。
以下にあげる機能は将来削除されたり互換性のない仕様変更がなされるかもしれません。
1.9.1 以降は安定版です。
バグ修正がメインになります。
記号について(特に重要なもの......* [bug]: バグ修正
* [new]: 追加されたクラス/メソッドなど
* [compat]: 変更されたクラス/メソッドなど(互換性のある変更) (only backward-compatibility) (影響の範囲が小さいと思われる変更もこちら)
* [change]: 変更されたクラス......tination オプションの追加
((<ruby-dev:28417>))
=== 2006-02-15
: instance_eval
((<ruby-core:7365>))
=== 2006-02-03
: Integer#upto [compat]
: Integer#downto [compat]
: Integer#doitems [compat]
ブロックがなければ enumerator を返す
: Enumerable#group_by [new]
: Enum...