class Bosh::Common::Version::VersionList

Attributes

versions[R]

Public Class Methods

new(versions) click to toggle source

@param [Array<#version>] Collection of SemiSemanticVersion objects

# File lib/common/version/version_list.rb, line 20
def initialize(versions)
  raise TypeError, "Invalid Version Array: '#{versions.inspect}'" unless versions.kind_of?(Array)
  @versions = versions
end
parse(versions, version_type) click to toggle source

@param [Array<#version>] Collection of version strings @param [class] Version type to parse as (ex: SemiSemanticVersion, ReleaseVersion, StemcellVersion, BoshVersion)

# File lib/common/version/version_list.rb, line 14
def self.parse(versions, version_type)
  raise TypeError, "Failed to Parse - Invalid Version Type: '#{version_type.inspect}'" unless version_type <= SemiSemanticVersion
  self.new(versions.map { |v| version_type.parse(v) })
end

Public Instance Methods

==(other) click to toggle source
# File lib/common/version/version_list.rb, line 47
def ==(other)
  @versions == other.versions
end
each(&block) click to toggle source
# File lib/common/version/version_list.rb, line 43
def each(&block)
  @versions.each(&block)
end
latest_with_pre_release(version) click to toggle source

Gets the latest version with the same release and pre-release version as the specified version @param [#version] SemiSemanticVersion object

# File lib/common/version/version_list.rb, line 27
def latest_with_pre_release(version)
  raise TypeError, "Invalid Version Type: #{version.class}" unless version.kind_of?(SemiSemanticVersion)
  @versions.select { |v|
    v.version.release == version.version.release && v.version.pre_release == version.version.pre_release
  }.max
end
latest_with_release(version) click to toggle source

Gets the latest version with the same release version as the specified version @param [#version] SemiSemanticVersion object

# File lib/common/version/version_list.rb, line 36
def latest_with_release(version)
  raise TypeError, "Invalid Version Type: #{version.class}" unless version.kind_of?(SemiSemanticVersion)
  @versions.select { |v|
    v.version.release == version.version.release
  }.max
end
to_s() click to toggle source
# File lib/common/version/version_list.rb, line 51
def to_s
  @versions.map{ |v| v.to_s }.to_s
end