Class: DebImporter::Version

Inherits:
Object
  • Object
show all
Defined in:
lib/deb_importer.rb

Overview

def

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(version_string) ⇒ Version

Returns a new instance of Version.



155
156
157
158
159
160
161
162
163
164
165
# File 'lib/deb_importer.rb', line 155

def initialize(version_string)
  @version_string = version_string
  # Split into "[epoch:]upstream[-revision]"
  # See: https://www.debian.org/doc/debian-policy/ch-controlfields.html#version
  unless /^((?<epoch>\d+)\:)?(?<upstream>.+?)(\-(?<revision>.+))?$/ =~ version_string
    raise ArgumentError, "Cannot parse version string: #{version_string}"
  end
  @epoch = epoch ? epoch : '0'
  @upstream = upstream
  @revision = revision if revision
end

Instance Attribute Details

#epochObject (readonly)

Returns the value of attribute epoch.



153
154
155
# File 'lib/deb_importer.rb', line 153

def epoch
  @epoch
end

#revisionObject (readonly)

Returns the value of attribute revision.



153
154
155
# File 'lib/deb_importer.rb', line 153

def revision
  @revision
end

#upstreamObject (readonly)

Returns the value of attribute upstream.



153
154
155
# File 'lib/deb_importer.rb', line 153

def upstream
  @upstream
end

#version_stringObject (readonly)

Returns the value of attribute version_string.



153
154
155
# File 'lib/deb_importer.rb', line 153

def version_string
  @version_string
end

Instance Method Details

#<(other) ⇒ Object



175
176
177
# File 'lib/deb_importer.rb', line 175

def <(other)
  dpkg_compare_version(@version_string, other, 'lt')
end

#>(other) ⇒ Object



171
172
173
# File 'lib/deb_importer.rb', line 171

def >(other)
  dpkg_compare_version(@version_string, other, 'gt')
end

#to_sObject

/def



167
168
169
# File 'lib/deb_importer.rb', line 167

def to_s
  @version_string
end