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.



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

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.



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

def e
  @e
end

#rObject (readonly) Also known as: release

Returns the value of attribute r.



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

def r
  @r
end

#vObject (readonly) Also known as: version

Returns the value of attribute v.



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

def v
  @v
end

Class Method Details

.parse(*args) ⇒ Object



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

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

Instance Method Details

#<=>(other) ⇒ Object



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

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

#compare(other) ⇒ Object



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

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

#evrObject



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

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

#partial_compare(other) ⇒ Object



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

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

#to_sObject

RPM::Version rpm_version_to_s equivalent



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

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