Class: Chef::Provider::Package::Yum::RPMVersion

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/chef/provider/package/yum/rpm_utils.rb

Overview

RPMUtils

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ RPMVersion

Returns a new instance of RPMVersion


225
226
227
228
229
230
231
232
233
234
235
236
# File 'lib/chef/provider/package/yum/rpm_utils.rb', line 225

def initialize(*args)
  if args.size == 1
    @e, @v, @r = RPMUtils.version_parse(args[0])
  elsif args.size == 3
    @e = args[0].to_i
    @v = args[1]
    @r = args[2]
  else
    raise ArgumentError, "Expecting either 'epoch-version-release' or 'epoch, " \
      "version, release'"
  end
end

Instance Attribute Details

#eObject (readonly) Also known as: epoch

Returns the value of attribute e


237
238
239
# File 'lib/chef/provider/package/yum/rpm_utils.rb', line 237

def e
  @e
end

#rObject (readonly) Also known as: release

Returns the value of attribute r


237
238
239
# File 'lib/chef/provider/package/yum/rpm_utils.rb', line 237

def r
  @r
end

#vObject (readonly) Also known as: version

Returns the value of attribute v


237
238
239
# File 'lib/chef/provider/package/yum/rpm_utils.rb', line 237

def v
  @v
end

Class Method Details

.parse(*args) ⇒ Object


242
243
244
# File 'lib/chef/provider/package/yum/rpm_utils.rb', line 242

def self.parse(*args)
  new(*args)
end

Instance Method Details

#<=>(other) ⇒ Object


246
247
248
# File 'lib/chef/provider/package/yum/rpm_utils.rb', line 246

def <=>(other)
  compare_versions(other)
end

#compare(other) ⇒ Object


250
251
252
# File 'lib/chef/provider/package/yum/rpm_utils.rb', line 250

def compare(other)
  compare_versions(other, false)
end

#evrObject


267
268
269
# File 'lib/chef/provider/package/yum/rpm_utils.rb', line 267

def evr
  "#{@e}:#{@v}-#{@r}"
end

#partial_compare(other) ⇒ Object


254
255
256
# File 'lib/chef/provider/package/yum/rpm_utils.rb', line 254

def partial_compare(other)
  compare_versions(other, true)
end

#to_sObject

RPM::Version rpm_version_to_s equivalent


259
260
261
262
263
264
265
# File 'lib/chef/provider/package/yum/rpm_utils.rb', line 259

def to_s
  if @r.nil?
    @v
  else
    "#{@v}-#{@r}"
  end
end