Class: SkadateGems::Dev::SoftwareVersion
- Inherits:
-
Object
- Object
- SkadateGems::Dev::SoftwareVersion
- Defined in:
- lib/skadategems/dev/software_version.rb
Overview
Represents Skadate software version
Defined Under Namespace
Classes: CompatibilityError
Instance Attribute Summary collapse
-
#build ⇒ Object
readonly
Returns the value of attribute build.
-
#codename ⇒ Object
readonly
Returns the value of attribute codename.
-
#major ⇒ Object
readonly
Returns the value of attribute major.
-
#minor ⇒ Object
readonly
Returns the value of attribute minor.
-
#release_date ⇒ Object
readonly
Returns the value of attribute release_date.
Instance Method Summary collapse
-
#==(other) ⇒ Object
Versions equality operator.
-
#initialize(version, release_date = nil, codename = nil) ⇒ SoftwareVersion
constructor
A new instance of SoftwareVersion.
-
#supported? ⇒ boolean
True if current version is supported by ‘skadategems-dev`.
-
#to_s ⇒ String
Version string representation.
Constructor Details
#initialize(version, release_date = nil, codename = nil) ⇒ SoftwareVersion
Returns a new instance of SoftwareVersion.
19 20 21 22 23 |
# File 'lib/skadategems/dev/software_version.rb', line 19 def initialize(version, release_date = nil, codename = nil) @major, @minor, @build = version.split('.', 3).map { |n| n.to_i } @release_date = release_date @codename = codename end |
Instance Attribute Details
#build ⇒ Object (readonly)
Returns the value of attribute build.
12 13 14 |
# File 'lib/skadategems/dev/software_version.rb', line 12 def build @build end |
#codename ⇒ Object (readonly)
Returns the value of attribute codename.
14 15 16 |
# File 'lib/skadategems/dev/software_version.rb', line 14 def codename @codename end |
#major ⇒ Object (readonly)
Returns the value of attribute major.
10 11 12 |
# File 'lib/skadategems/dev/software_version.rb', line 10 def major @major end |
#minor ⇒ Object (readonly)
Returns the value of attribute minor.
11 12 13 |
# File 'lib/skadategems/dev/software_version.rb', line 11 def minor @minor end |
#release_date ⇒ Object (readonly)
Returns the value of attribute release_date.
13 14 15 |
# File 'lib/skadategems/dev/software_version.rb', line 13 def release_date @release_date end |
Instance Method Details
#==(other) ⇒ Object
Versions equality operator
31 32 33 34 35 36 37 38 39 |
# File 'lib/skadategems/dev/software_version.rb', line 31 def == (other) return other == to_s if other.instance_of?(String) return false unless other.instance_of?(SoftwareVersion) @major == other.major && @minor == other.minor && @build == other.build end |
#supported? ⇒ boolean
Returns true if current version is supported by ‘skadategems-dev`.
42 43 44 |
# File 'lib/skadategems/dev/software_version.rb', line 42 def supported? MAP.key?(to_s) end |
#to_s ⇒ String
Returns version string representation.
26 27 28 |
# File 'lib/skadategems/dev/software_version.rb', line 26 def to_s "#{@major}.#{@minor}.#{@build}" end |