Class: Version

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/version.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#partsObject

Returns the value of attribute parts.



3
4
5
# File 'lib/version.rb', line 3

def parts
  @parts
end

#to_sObject

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