Class: Enumerator.self::Chain
- Defined in:
- opal/opal/corelib/enumerator/chain.rb
Instance Method Summary collapse
- #each(*args, &block) ⇒ Object
-
#initialize(*enums) ⇒ Chain
constructor
A new instance of Chain.
- #inspect ⇒ Object
- #rewind ⇒ Object
- #size(*args) ⇒ Object
Constructor Details
#initialize(*enums) ⇒ Chain
Returns a new instance of Chain.
3 4 5 6 7 |
# File 'opal/opal/corelib/enumerator/chain.rb', line 3 def initialize(*enums) @enums = enums @iterated = [] @object = self end |
Instance Method Details
#each(*args, &block) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'opal/opal/corelib/enumerator/chain.rb', line 9 def each(*args, &block) return to_enum(:each, *args) { size } unless block_given? @enums.each do |enum| @iterated << enum enum.each(*args, &block) end self end |
#inspect ⇒ Object
38 39 40 |
# File 'opal/opal/corelib/enumerator/chain.rb', line 38 def inspect "#<Enumerator::Chain: #{@enums.inspect}>" end |
#rewind ⇒ Object
30 31 32 33 34 35 36 |
# File 'opal/opal/corelib/enumerator/chain.rb', line 30 def rewind @iterated.reverse_each do |enum| enum.rewind if enum.respond_to? :rewind end @iterated = [] self end |