In Files

  • mrbgems/mruby-enum-chain/mrblib/chain.rb

Enumerator::Chain

Public Class Methods

new(*args) click to toggle source
 
               # File mrbgems/mruby-enum-chain/mrblib/chain.rb, line 19
def initialize(*args)
  @enums = args
end
            

Public Instance Methods

__copy_enums() click to toggle source
 
               # File mrbgems/mruby-enum-chain/mrblib/chain.rb, line 54
def __copy_enums
  @enums.each_with_object([]) do |e, a|
    a << e.clone
  end
end
            
each(&block) click to toggle source
 
               # File mrbgems/mruby-enum-chain/mrblib/chain.rb, line 27
def each(&block)
  return to_enum unless block_given?

  @enums.each { |e| e.each(&block) }

  self
end
            
initialize_copy(orig) click to toggle source
 
               # File mrbgems/mruby-enum-chain/mrblib/chain.rb, line 23
def initialize_copy(orig)
  @enums = orig.__copy_enums
end
            
inspect() click to toggle source
 
               # File mrbgems/mruby-enum-chain/mrblib/chain.rb, line 50
def inspect
  "#<#{self.class}: #{@enums.inspect}>"
end
            
rewind() click to toggle source
 
               # File mrbgems/mruby-enum-chain/mrblib/chain.rb, line 42
def rewind
  @enums.reverse_each do |e|
    e.rewind if e.respond_to?(:rewind)
  end

  self
end
            
size() click to toggle source
 
               # File mrbgems/mruby-enum-chain/mrblib/chain.rb, line 35
def size
  @enums.reduce(0) do |a, e|
    return nil unless e.respond_to?(:size)
    a + e.size
  end
end