Class: Liferaft::Version
- Inherits:
-
Object
- Object
- Liferaft::Version
- Defined in:
- lib/liferaft/version.rb
Instance Attribute Summary collapse
-
#build ⇒ Object
readonly
Returns the value of attribute build.
-
#major ⇒ Object
readonly
Returns the value of attribute major.
-
#minor ⇒ Object
readonly
Returns the value of attribute minor.
-
#patch ⇒ Object
readonly
Returns the value of attribute patch.
Instance Method Summary collapse
- #<(other) ⇒ Object
- #<=(other) ⇒ Object
- #==(other) ⇒ Object
- #>(other) ⇒ Object
- #>=(other) ⇒ Object
-
#initialize(version_string) ⇒ Version
constructor
A new instance of Version.
Constructor Details
#initialize(version_string) ⇒ Version
Returns a new instance of Version.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/liferaft/version.rb', line 9 def initialize(version_string) components = version_string.downcase.split(/[a-z]/) character = version_string.downcase.gsub(/[^a-z]/, '') if character.length != 1 @major = @minor = @patch = @build = 0 return end @major = components[0].to_i @minor = character.ord - 'a'.ord @patch = components[1].to_i / 1000 @build = components[1].to_i % 1000 end |
Instance Attribute Details
#build ⇒ Object (readonly)
Returns the value of attribute build.
7 8 9 |
# File 'lib/liferaft/version.rb', line 7 def build @build end |
#major ⇒ Object (readonly)
Returns the value of attribute major.
7 8 9 |
# File 'lib/liferaft/version.rb', line 7 def major @major end |
#minor ⇒ Object (readonly)
Returns the value of attribute minor.
7 8 9 |
# File 'lib/liferaft/version.rb', line 7 def minor @minor end |
#patch ⇒ Object (readonly)
Returns the value of attribute patch.
7 8 9 |
# File 'lib/liferaft/version.rb', line 7 def patch @patch end |
Instance Method Details
#<(other) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/liferaft/version.rb', line 32 def <(other) return true if major < other.major return true if minor < other.minor return true if patch < other.patch build < other.build end |
#<=(other) ⇒ Object
39 40 41 |
# File 'lib/liferaft/version.rb', line 39 def <=(other) self < other || other == self end |
#==(other) ⇒ Object
43 44 45 46 47 |
# File 'lib/liferaft/version.rb', line 43 def ==(other) other.instance_of?(self.class) && major == other.major && minor == other.minor && patch == other.patch && build == other.build end |
#>(other) ⇒ Object
24 25 26 |
# File 'lib/liferaft/version.rb', line 24 def >(other) other < self end |
#>=(other) ⇒ Object
28 29 30 |
# File 'lib/liferaft/version.rb', line 28 def >=(other) other < self || other == self end |