This class represents a sorted collection of Geminabox::GemVersion objects. It it used widely throughout the system for displaying and filtering gems.
Array of Geminabox::GemVersion objects, or an array of [name, version, platform] triples.
# File lib/geminabox/gem_version_collection.rb, line 10 def initialize(initial_gems=[]) @gems = initial_gems.map{|object| coerce_to_gem_version(object) }.sort end
The collection can contain gems of different names, this method groups them by name, and then sorts the different version of each name by version and platform.
yields 'foo_gem', version_collection
# File lib/geminabox/gem_version_collection.rb, line 41 def by_name(&block) @grouped ||= @gems.group_by(&:name).map{|name, collection| [name, Geminabox::GemVersionCollection.new(collection)] }.sort_by{|name, collection| name.downcase } if block_given? @grouped.each(&block) else @grouped end end
# File lib/geminabox/gem_version_collection.rb, line 32 def each(&block) @gems.each(&block) end
FIXME: Terminology makes no sense when the version are not all of the same name
# File lib/geminabox/gem_version_collection.rb, line 24 def newest @gems.last end
Generated with the Darkfish Rdoc Generator 2.