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

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/chef/provider/package/yum.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.



231
232
233
234
235
236
237
238
239
240
241
242
# File 'lib/chef/provider/package/yum.rb', line 231

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.



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

def e
  @e
end

#rObject (readonly) Also known as: release

Returns the value of attribute r.



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

def r
  @r
end

#vObject (readonly) Also known as: version

Returns the value of attribute v.



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

def v
  @v
end

Class Method Details

.parse(*args) ⇒ Object



248
249
250
# File 'lib/chef/provider/package/yum.rb', line 248

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

Instance Method Details

#<=>(y) ⇒ Object



252
253
254
# File 'lib/chef/provider/package/yum.rb', line 252

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

#compare(y) ⇒ Object



256
257
258
# File 'lib/chef/provider/package/yum.rb', line 256

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

#evrObject



273
274
275
# File 'lib/chef/provider/package/yum.rb', line 273

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

#partial_compare(y) ⇒ Object



260
261
262
# File 'lib/chef/provider/package/yum.rb', line 260

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

#to_sObject

RPM::Version rpm_version_to_s equivalent



265
266
267
268
269
270
271
# File 'lib/chef/provider/package/yum.rb', line 265

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