class Gemirro::GemVersionCollection
The VersionCollection class contains a collection of ::Gem::Version
@!attribute [r] gems
@return [Array]
@!attribute [r] grouped
@return [Array]
Attributes
Public Class Methods
Source
# File lib/gemirro/gem_version_collection.rb, line 20 def initialize(gems = []) @gems = gems.map do |object| if object.is_a?(GemVersion) object else GemVersion.new(*object) end end @gems.sort_by!(&:version) end
@param [Array] gems
Public Instance Methods
Source
# File lib/gemirro/gem_version_collection.rb, line 72 def by_name(&block) if @grouped.nil? @grouped = @gems.group_by(&:name).map do |name, collection| [name, GemVersionCollection.new(collection)] end @grouped.reject! do |name, _collection| name.nil? end @grouped.sort_by! do |name, _collection| name.downcase end end if block_given? @grouped.each(&block) else @grouped end end
Group gems by name
@param [Proc] block @return [Array]
Source
# File lib/gemirro/gem_version_collection.rb, line 62 def each(&block) @gems.each(&block) end
Each method
Source
# File lib/gemirro/gem_version_collection.rb, line 100 def find_by_name(gemname) gem = by_name.select do |name, _collection| name == gemname end gem.first.last if gem.any? end
Find gem by name
@param [String] gemname @return [Array]
Source
# File lib/gemirro/gem_version_collection.rb, line 46 def newest @gems.last end
Return newest version of a gem
@return [GemVersion]
Source
# File lib/gemirro/gem_version_collection.rb, line 37 def oldest @gems.first end
Return oldest version of a gem
@return [GemVersion]
Source
# File lib/gemirro/gem_version_collection.rb, line 55 def size @gems.size end
Return size of a gem
@return [Integer]