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.
5 6 7 8 9 10 11 |
# File 'opal/opal/corelib/enumerator/chain.rb', line 5 def initialize(*enums) `$deny_frozen_access(self)` @enums = enums @iterated = [] @object = self end |
Instance Method Details
#each(*args, &block) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'opal/opal/corelib/enumerator/chain.rb', line 13 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
42 43 44 |
# File 'opal/opal/corelib/enumerator/chain.rb', line 42 def inspect "#<Enumerator::Chain: #{@enums.inspect}>" end |
#rewind ⇒ Object
34 35 36 37 38 39 40 |
# File 'opal/opal/corelib/enumerator/chain.rb', line 34 def rewind @iterated.reverse_each do |enum| enum.rewind if enum.respond_to? :rewind end @iterated = [] self end |