Class: Adhearsion::PkgVersion
- Includes:
- Comparable
- Defined in:
- lib/adhearsion/version.rb
Instance Attribute Summary collapse
-
#major ⇒ Object
readonly
Returns the value of attribute major.
-
#minor ⇒ Object
readonly
Returns the value of attribute minor.
-
#revision ⇒ Object
readonly
Returns the value of attribute revision.
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(version = "") ⇒ PkgVersion
constructor
A new instance of PkgVersion.
- #to_s ⇒ Object
Constructor Details
#initialize(version = "") ⇒ PkgVersion
Returns a new instance of PkgVersion.
15 16 17 |
# File 'lib/adhearsion/version.rb', line 15 def initialize(version="") @major, @minor, @revision = version.split(".").map(&:to_i) end |
Instance Attribute Details
#major ⇒ Object (readonly)
Returns the value of attribute major.
13 14 15 |
# File 'lib/adhearsion/version.rb', line 13 def major @major end |
#minor ⇒ Object (readonly)
Returns the value of attribute minor.
13 14 15 |
# File 'lib/adhearsion/version.rb', line 13 def minor @minor end |
#revision ⇒ Object (readonly)
Returns the value of attribute revision.
13 14 15 |
# File 'lib/adhearsion/version.rb', line 13 def revision @revision end |
Class Method Details
.sort ⇒ Object
25 26 27 |
# File 'lib/adhearsion/version.rb', line 25 def self.sort self.sort!{|a,b| a <=> b} end |
Instance Method Details
#<=>(other) ⇒ Object
19 20 21 22 23 |
# File 'lib/adhearsion/version.rb', line 19 def <=>(other) return @major <=> other.major if ((@major <=> other.major) != 0) return @minor <=> other.minor if ((@minor <=> other.minor) != 0) return @revision <=> other.revision if ((@revision <=> other.revision) != 0) end |
#to_s ⇒ Object
29 30 31 |
# File 'lib/adhearsion/version.rb', line 29 def to_s @major.to_s + "." + @minor.to_s + "." + @revision.to_s end |