Class: Version
Instance Attribute Summary collapse
-
#parts ⇒ Object
Returns the value of attribute parts.
-
#to_s ⇒ Object
Returns the value of attribute to_s.
Instance Method Summary collapse
- #<=>(that) ⇒ Object
-
#initialize(string) ⇒ Version
constructor
A new instance of Version.
Constructor Details
#initialize(string) ⇒ Version
Returns a new instance of Version.
5 6 7 8 9 |
# File 'lib/version.rb', line 5 def initialize(string) string.strip! @to_s = string @parts = string.split(".").map{|x| x.to_i} end |
Instance Attribute Details
#parts ⇒ Object
Returns the value of attribute parts.
3 4 5 |
# File 'lib/version.rb', line 3 def parts @parts end |
#to_s ⇒ Object
Returns the value of attribute to_s.
3 4 5 |
# File 'lib/version.rb', line 3 def to_s @to_s end |
Instance Method Details
#<=>(that) ⇒ Object
11 12 13 |
# File 'lib/version.rb', line 11 def <=>(that) self.parts <=> that.parts end |