Class: Adhearsion::PkgVersion

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#majorObject (readonly)

Returns the value of attribute major.



13
14
15
# File 'lib/adhearsion/version.rb', line 13

def major
  @major
end

#minorObject (readonly)

Returns the value of attribute minor.



13
14
15
# File 'lib/adhearsion/version.rb', line 13

def minor
  @minor
end

#revisionObject (readonly)

Returns the value of attribute revision.



13
14
15
# File 'lib/adhearsion/version.rb', line 13

def revision
  @revision
end

Class Method Details

.sortObject



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_sObject



29
30
31
# File 'lib/adhearsion/version.rb', line 29

def to_s
  @major.to_s + "." + @minor.to_s + "." + @revision.to_s
end