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.



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

#buildObject (readonly)

Returns the value of attribute build.



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

def build
  @build
end

#majorObject (readonly)

Returns the value of attribute major.



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

def major
  @major
end

#minorObject (readonly)

Returns the value of attribute minor.



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

def minor
  @minor
end

#revisionObject (readonly)

Returns the value of attribute revision.



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

def revision
  @revision
end

Class Method Details

.sortObject



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_sObject



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