Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Enumerator::Chain document sicne Ruby 2.6.0 #2272

Merged
merged 4 commits into from
Jun 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions refm/api/src/_builtin.rd
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ require を書かなくても使うことができます。
#@include(_builtin/Enumerator)
#@since 2.6.0
#@include(_builtin/Enumerator__ArithmeticSequence)
#@include(_builtin/Enumerator__Chain)
#@end
#@since 2.0.0
#@include(_builtin/Enumerator__Lazy)
Expand Down
13 changes: 13 additions & 0 deletions refm/api/src/_builtin/Enumerable
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,19 @@
p [].any? # => false
#@end

#@since 2.6.0
--- chain(*enums) -> Enumerator::Chain

自身と enums 引数を続けて繰り返す [[c:Enumerator::Chain]] を返します。

#@samplecode 例
e = (1..3).chain([4, 5])
e.to_a #=> [1, 2, 3, 4, 5]
#@end

@see [[m:Enumerator#+]]
#@end

#@since 1.9.1
--- collect -> Enumerator
--- map -> Enumerator
Expand Down
13 changes: 13 additions & 0 deletions refm/api/src/_builtin/Enumerator
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,19 @@ new に渡されたブロックが終了した時点で each の繰り返しが

== Methods

#@since 2.6.0
--- +(enum) -> Enumerator::Chain

自身と enum 引数を続けて繰り返す [[c:Enumerator::Chain]] を返します。

#@samplecode 例
e = (1..3).each + [4, 5]
e.to_a #=> [1, 2, 3, 4, 5]
#@end

@see [[m:Enumerable#chain]]
#@end

--- each {...} -> object
--- each -> self
--- each(*args) {...} -> object
Expand Down
47 changes: 47 additions & 0 deletions refm/api/src/_builtin/Enumerator__Chain
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
= class Enumerator::Chain < Enumerator

複数の繰り返し可能なオブジェクトを1つの Enumerator として扱うためのクラス。

Enumerator::Chain のオブジェクトは、[[m:Enumerable#chain]] や [[m:Enumerator#+]] から作られます。

== Class Methods

--- new(*enums) -> Enumerator::Chain

複数の Enumerable から、1つの新しい Enumerator を作って返します。

#@samplecode 例
e = Enumerator::Chain.new(1..3, [4, 5])
e.to_a #=> [1, 2, 3, 4, 5]
e.size #=> 5
#@end

== Instance Methods

--- each(*args) { |*args| ...} -> object
--- each(*args) -> Enumerator

まず最初の繰り返し可能なオブジェクトの each メソッドを
args 引数とともに呼び出した後、続く繰り返し可能なオブジェクト
も同様に呼び出します。

ブロックが渡されない場合は [[c:Enumerator]] を返します。

--- inspect -> String

self を人間が読みやすい形式で文字列として返します。

--- rewind -> object

列挙状態を巻き戻します。

self が持つ繰り返し可能なオブジェクトに対して、逆順で rewind メソッドを呼びます。
ただし rewind メソッドを持たないオブジェクトに対しては rewind メソッドを呼びません。

--- size -> Integer | Float::INFINITY | nil

合計の要素数を返します。

それぞれの列挙可能なオブジェクトのサイズの合計値を返します。
ただし、列挙可能なオブジェクトが1つでも nil か [[m:Float::INFINITY]]
を返した場合、それを合計の要素数として返します。