123456789_123456789_123456789_123456789_123456789_

Class: REXML::SyncEnumerator

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
self, Enumerable
Inherits: Object
Defined in: lib/rexml/syncenumerator.rb

Class Method Summary

Instance Method Summary

  • #each

    Enumerates rows of the Enumerable objects.

  • #length

    Returns the number of enumerated Enumerable objects, i.e.

  • #size

    Returns the number of enumerated Enumerable objects, i.e.

Constructor Details

.new(*enums) ⇒ SyncEnumerator

Creates a new SyncEnumerator which enumerates rows of given Enumerable objects.

[ GitHub ]

  
# File 'lib/rexml/syncenumerator.rb', line 7

def initialize(*enums)
  @gens = enums
  @length = @gens.collect {|x| x.size }.max
end

Instance Method Details

#each

Enumerates rows of the Enumerable objects.

[ GitHub ]

  
# File 'lib/rexml/syncenumerator.rb', line 25

def each
  @length.times {|i|
    yield @gens.collect {|x| x[i]}
  }
  self
end

#length

Returns the number of enumerated Enumerable objects, i.e. the size of each row.

[ GitHub ]

  
# File 'lib/rexml/syncenumerator.rb', line 20

def length
  @gens.length
end

#size

Returns the number of enumerated Enumerable objects, i.e. the size of each row.

[ GitHub ]

  
# File 'lib/rexml/syncenumerator.rb', line 14

def size
  @gens.size
end