class Serverspec::Type::Package::Version
Attributes
epoch[R]
version[R]
Public Class Methods
new(val)
click to toggle source
# File lib/serverspec/type/package.rb, line 27 def initialize(val) matches = val.match(/^(?:(\d+):)?(\d[0-9a-zA-Z.+:~_-]*)$/) if matches.nil? raise ArgumentError, "Malformed version number string #{val}" end @epoch = matches[1].to_i @version = matches[2].to_s end
Public Instance Methods
<=>(other)
click to toggle source
# File lib/serverspec/type/package.rb, line 36 def <=>(other) other = Version.new(other) if other.is_a?(String) rv = @epoch <=> other.epoch return rv if rv != 0 self.ver_array <=> other.ver_array end
ver_array()
click to toggle source
# File lib/serverspec/type/package.rb, line 44 def ver_array val = @version re = /^(?:(\d+)|(\D+))(.*)$/ res = [] until val.empty? matches = val.match(re) if matches[1].nil? # String matches[2].to_s.each_byte do |b| code_point = defined?("~".ord) ? "~".ord : ?~ res << ((b == code_point) ? -2 : b) end else # Digits res << matches[1].to_i end val = matches[3].to_s end res << -1 end