Class: EnumerableFu::Merger::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/enumerable_fu/merging.rb

Instance Method Summary collapse

Constructor Details

#initialize(enumerators, transformer) ⇒ Generator

Returns a new instance of Generator.


19
20
21
22
# File 'lib/enumerable_fu/merging.rb', line 19

def initialize(enumerators, transformer)
  @enumerators = enumerators
  @transformer = transformer
end

Instance Method Details

#eachObject


24
25
26
27
28
29
30
# File 'lib/enumerable_fu/merging.rb', line 24

def each
  while true do
    discard_empty_enumerators
    break if @enumerators.empty?
    yield next_enumerator.next
  end
end