Class: Version
Instance Attribute Summary collapse
-
#bugfix ⇒ Object
readonly
Returns the value of attribute bugfix.
-
#feature ⇒ Object
readonly
Returns the value of attribute feature.
-
#feature_group ⇒ Object
readonly
Returns the value of attribute feature_group.
-
#major ⇒ Object
readonly
Returns the value of attribute major.
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(version = "") ⇒ Version
constructor
A new instance of Version.
- #to_s ⇒ Object
Constructor Details
#initialize(version = "") ⇒ Version
Returns a new instance of Version.
6 7 8 9 10 11 12 |
# File 'lib/coderunner/version.rb', line 6 def initialize(version="") v = version.split(".") @major = v[0].to_i @feature_group = v[1] ? v[1].to_i : 0 @feature = v[2] ? v[2].to_i : 0 @bugfix = v[2] ? v[3].to_i : 0 end |
Instance Attribute Details
#bugfix ⇒ Object (readonly)
Returns the value of attribute bugfix.
4 5 6 |
# File 'lib/coderunner/version.rb', line 4 def bugfix @bugfix end |
#feature ⇒ Object (readonly)
Returns the value of attribute feature.
4 5 6 |
# File 'lib/coderunner/version.rb', line 4 def feature @feature end |
#feature_group ⇒ Object (readonly)
Returns the value of attribute feature_group.
4 5 6 |
# File 'lib/coderunner/version.rb', line 4 def feature_group @feature_group end |
#major ⇒ Object (readonly)
Returns the value of attribute major.
4 5 6 |
# File 'lib/coderunner/version.rb', line 4 def major @major end |
Class Method Details
.sort ⇒ Object
20 21 22 |
# File 'lib/coderunner/version.rb', line 20 def self.sort self.sort!{|a,b| a <=> b} end |
Instance Method Details
#<=>(other) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/coderunner/version.rb', line 14 def <=>(other) return @major <=> other.major if ((@major <=> other.major) != 0) return @feature_group <=> other.feature_group if ((@feature_group <=> other.feature_group) != 0) return @feature <=> other.feature if ((@feature <=> other.feature) != 0) return @bugfix <=> other.bugfix end |
#to_s ⇒ Object
24 25 26 |
# File 'lib/coderunner/version.rb', line 24 def to_s @major.to_s + "." + @feature_group.to_s + "." + @feature.to_s + "." + @bugfix.to_s end |