Module: Enumerable
- Included in:
- LazyEnumerator
- Defined in:
- lib/coroutines.rb
Overview
– Most of the Sink methods mirror Enumerable, except for <= for symmetry, also add a >= method to Enumerable ++
Instance Method Summary collapse
-
#>=(other) ⇒ Object
:call-seq: enum >= sink -> obj enum >= trans -> new_enum.
Instance Method Details
#>=(other) ⇒ Object
:call-seq:
enum >= sink -> obj
enum >= trans -> new_enum
In the first form, iterate over enum
and write each result to sink
using <<; then return the result of sink.close.
In the second form, create a new Enumerator by connecting enum
to the input of trans
(which must be convertible to a Transformer using the to_trans method).
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/coroutines.rb', line 18 def >=(other) if other.respond_to? :<< begin each { |x| other << x } rescue StopIteration end other.close elsif other.respond_to? :to_trans other <= self end end |