Class: Bosh::Common::Version::VersionList
- Inherits:
-
Object
- Object
- Bosh::Common::Version::VersionList
- Includes:
- Enumerable
- Defined in:
- lib/common/version/version_list.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#versions ⇒ Object
readonly
Returns the value of attribute versions.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(versions) ⇒ VersionList
constructor
A new instance of VersionList.
-
#latest_with_pre_release(version) ⇒ Object
Gets the latest version with the same release and pre-release version as the specified version.
-
#latest_with_release(version) ⇒ Object
Gets the latest version with the same release version as the specified version.
- #to_s ⇒ Object
Constructor Details
#initialize(versions) ⇒ VersionList
Returns a new instance of VersionList.
20 21 22 23 |
# 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 |
Instance Attribute Details
#versions ⇒ Object (readonly)
Returns the value of attribute versions.
8 9 10 |
# File 'lib/common/version/version_list.rb', line 8 def versions @versions end |
Class Method Details
.parse(versions, version_type) ⇒ Object
14 15 16 17 |
# 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 |
Instance Method Details
#==(other) ⇒ Object
47 48 49 |
# File 'lib/common/version/version_list.rb', line 47 def ==(other) @versions == other.versions end |
#each(&block) ⇒ Object
43 44 45 |
# File 'lib/common/version/version_list.rb', line 43 def each(&block) @versions.each(&block) end |
#latest_with_pre_release(version) ⇒ Object
Gets the latest version with the same release and pre-release version as the specified version
27 28 29 30 31 32 |
# 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) ⇒ Object
Gets the latest version with the same release version as the specified version
36 37 38 39 40 41 |
# 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 ⇒ Object
51 52 53 |
# File 'lib/common/version/version_list.rb', line 51 def to_s @versions.map{ |v| v.to_s }.to_s end |