Sha256: d95e51738cc024834b25d022869d18c3c89d95a6c2e37caccc01fdb64621b4e7

Contents?: true

Size: 721 Bytes

Versions: 2

Compression:

Stored size: 721 Bytes

Contents

module REXML
  class SyncEnumerator
    include Enumerable

    # Creates a new SyncEnumerator which enumerates rows of given
    # Enumerable objects.
    def initialize(*enums)
      @gens = enums
      @biggest = @gens[0]
      @gens.each {|x| @biggest = x if x.size > @biggest.size }
    end

    # Returns the number of enumerated Enumerable objects, i.e. the size
    # of each row.
    def size
      @gens.size
    end

    # Returns the number of enumerated Enumerable objects, i.e. the size
    # of each row.
    def length
      @gens.length
    end

    # Enumerates rows of the Enumerable objects.
    def each
      @biggest.zip( *@gens ) {|a|
        yield(*a[1..-1])
      }
      self
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
rubysl-rexml-1.0.0 lib/rexml/syncenumerator.rb
ruby_on_ruby-0.0.1 vendor/javascripts/emscripted-ruby/lib/rexml/syncenumerator.rb