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
- #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.
Constructor Details
#initialize(versions) ⇒ VersionList
Returns a new instance of VersionList.
19 20 21 |
# File 'lib/common/version/version_list.rb', line 19 def initialize(versions) @versions = versions end |
Instance Attribute Details
#versions ⇒ Object (readonly)
Returns the value of attribute versions.
7 8 9 |
# File 'lib/common/version/version_list.rb', line 7 def versions @versions end |
Class Method Details
.parse(versions, version_type) ⇒ Object
13 14 15 16 |
# File 'lib/common/version/version_list.rb', line 13 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
#each(&block) ⇒ Object
41 42 43 |
# File 'lib/common/version/version_list.rb', line 41 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
25 26 27 28 29 30 |
# File 'lib/common/version/version_list.rb', line 25 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
34 35 36 37 38 39 |
# File 'lib/common/version/version_list.rb', line 34 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 |