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