1 module REXML
2 class SyncEnumerator
3 include Enumerable
4
5 # Creates a new SyncEnumerator which enumerates rows of given
6 # Enumerable objects.
7 def initialize(*enums)
8 @gens = enums
9 @biggest = @gens[0]
10 @gens.each {|x| @biggest = x if x.size > @biggest.size }
11 end
12
13 # Returns the number of enumerated Enumerable objects, i.e. the size
14 # of each row.
15 def size
16 @gens.size
17 end
18
19 # Returns the number of enumerated Enumerable objects, i.e. the size
20 # of each row.
21 def length
22 @gens.length
23 end
24
25 # Enumerates rows of the Enumerable objects.
26 def each
27 @biggest.zip( *@gens ) {|a|
28 yield(*a[1..-1])
29 }
30 self
31 end
32 end
33 end