Class: Relix::Version
- Inherits:
-
Object
- Object
- Relix::Version
- Includes:
- Comparable
- Defined in:
- lib/relix/version.rb
Instance Attribute Summary collapse
-
#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
-
#initialize(version) ⇒ Version
constructor
A new instance of Version.
Constructor Details
#initialize(version) ⇒ Version
Returns a new instance of Version.
9 10 11 12 13 |
# File 'lib/relix/version.rb', line 9 def initialize(version) @major, @minor, @patch = version.to_s.split(".").collect{|e| e.to_i} @minor ||= 0 @patch ||= 0 end |
Instance Attribute Details
#major ⇒ Object (readonly)
Returns the value of attribute major.
8 9 10 |
# File 'lib/relix/version.rb', line 8 def major @major end |
#minor ⇒ Object (readonly)
Returns the value of attribute minor.
8 9 10 |
# File 'lib/relix/version.rb', line 8 def minor @minor end |
#patch ⇒ Object (readonly)
Returns the value of attribute patch.
8 9 10 |
# File 'lib/relix/version.rb', line 8 def patch @patch end |
Instance Method Details
#<=>(other) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/relix/version.rb', line 15 def <=>(other) case other when String (self <=> Version.new(other)) else if((r = (major <=> other.major)) != 0) r elsif((r = (minor <=> other.minor)) != 0) r else (patch <=> other.patch) end end end |