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