Class: MetaCon::CLIHelpers::SymVer
- Inherits:
-
Object
- Object
- MetaCon::CLIHelpers::SymVer
- Includes:
- Comparable
- Defined in:
- lib/metacon/cli_helpers.rb
Instance Attribute Summary collapse
-
#varr ⇒ Object
Returns the value of attribute varr.
Instance Method Summary collapse
- #<=>(other_v) ⇒ Object
-
#initialize(vstring) ⇒ SymVer
constructor
A new instance of SymVer.
Constructor Details
#initialize(vstring) ⇒ SymVer
Returns a new instance of SymVer.
10 11 12 |
# File 'lib/metacon/cli_helpers.rb', line 10 def initialize(vstring) @varr = vstring.split('.').map{|p| p.to_i} end |
Instance Attribute Details
#varr ⇒ Object
Returns the value of attribute varr.
9 10 11 |
# File 'lib/metacon/cli_helpers.rb', line 9 def varr @varr end |
Instance Method Details
#<=>(other_v) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/metacon/cli_helpers.rb', line 14 def <=>(other_v) (0..[other_v.varr.size,@varr.size].max).each do |i| s = @varr[i] || 0 o = other_v.varr[i] || 0 if s < o then return -1 elsif s > o then return 1 end end return 0 end |