Sha256: 23fb12c15df251507ea83a09796702b17741838995bebe9c559025789169b40b

Contents?: true

Size: 496 Bytes

Versions: 9

Compression:

Stored size: 496 Bytes

Contents

class Geminabox::GemVersionCollection
  include Enumerable

  def initialize(initial_gems = [])
    @gems = Hash.new{|h,k| h[k] = [] }
    initial_gems.each{|g| self << g }
  end

  def <<(gemdef)
    name,version,_ = gemdef
    @gems[name] += [version].flatten
    @gems[name].sort!
    self
  end
  
  def + other
    other.inject(self.class.new(self)){|new_set, gemdef|
      new_set << gemdef
    }
  end
  
  def each(&block)
    @gems.sort_by{|name, versions| name }.each(&block)
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
geminabox-0.2.14 lib/geminabox/gem_version_collection.rb
geminabox-0.2.13 lib/geminabox/gem_version_collection.rb
geminabox-0.2.11 lib/geminabox/gem_version_collection.rb
geminabox-0.2.10 lib/geminabox/gem_version_collection.rb
geminabox-0.2.9 lib/geminabox/gem_version_collection.rb
geminabox-0.2.9.pre1 lib/geminabox/gem_version_collection.rb
geminabox-0.2.8 lib/geminabox/gem_version_collection.rb
geminabox-0.2.7 lib/geminabox/gem_version_collection.rb
geminabox-0.2.6 lib/geminabox/gem_version_collection.rb