Class: Autoproj::PackageManagers::DebianVersion

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/autoproj/package_managers/debian_version.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(version) ⇒ DebianVersion

Returns a new instance of DebianVersion.



11
12
13
14
# File 'lib/autoproj/package_managers/debian_version.rb', line 11

def initialize(version)
    @version = version
    parse_version
end

Instance Attribute Details

#debian_revisionObject (readonly)

Returns the value of attribute debian_revision.



7
8
9
# File 'lib/autoproj/package_managers/debian_version.rb', line 7

def debian_revision
  @debian_revision
end

#epochObject (readonly)

Returns the value of attribute epoch.



5
6
7
# File 'lib/autoproj/package_managers/debian_version.rb', line 5

def epoch
  @epoch
end

#upstream_versionObject (readonly)

Returns the value of attribute upstream_version.



6
7
8
# File 'lib/autoproj/package_managers/debian_version.rb', line 6

def upstream_version
  @upstream_version
end

#versionObject (readonly)

Returns the value of attribute version.



4
5
6
# File 'lib/autoproj/package_managers/debian_version.rb', line 4

def version
  @version
end

Class Method Details

.compare(a, b) ⇒ Object



28
29
30
# File 'lib/autoproj/package_managers/debian_version.rb', line 28

def self.compare(a, b)
    new(a) <=> new(b)
end

Instance Method Details

#<=>(b) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/autoproj/package_managers/debian_version.rb', line 20

def <=>(b)
    (0..2).inject(0) do |result, i|
        return result unless result == 0

        normalize(compare_fragments(split[i], b.split[i]))
    end
end

#splitObject



16
17
18
# File 'lib/autoproj/package_managers/debian_version.rb', line 16

def split
    [epoch, upstream_version, debian_revision]
end