class EC2::Platform::Linux::Tar::Version

Constants

REGEX

Attributes

string[R]
values[R]

Public Class Methods

current() click to toggle source
# File lib/ec2/platform/linux/tar.rb, line 117
def self.current
  Version.new
end
new(str=nil) click to toggle source
# File lib/ec2/platform/linux/tar.rb, line 71
def initialize(str=nil)
  @string = str
  @string = default if str.nil? or str.empty?
  @values = Version.parse @string
end
parse(str) click to toggle source
# File lib/ec2/platform/linux/tar.rb, line 99
def self.parse(str)
  match = REGEX.match(str)
  return nil if match.nil?
  begin
    items = match.captures.collect do |cap|
      cap.sub!(/^0*/, "")
      case cap
      when ""
        num = 0
      else
        num = Integer(cap)
      end
    end
  rescue ArgumentError
    return nil
  end
  items
end

Public Instance Methods

>=(other) click to toggle source
# File lib/ec2/platform/linux/tar.rb, line 85
def >= (other)
  return nil if @values.nil?
  if other.nil? or not other.is_a? Version
    raise ArgumentError, "Cannot compare with invalid version #{other}"
  end
  @values.zip(other.values).each do |mine, others|
    return false if mine < others
    return true if mine > others
  end
  return true
end
default() click to toggle source
# File lib/ec2/platform/linux/tar.rb, line 76
def default
  s = `#{Command.new.version.expand}`.strip
  s = nil unless $? == 0
  s
end
string=(str) click to toggle source
# File lib/ec2/platform/linux/tar.rb, line 81
def string= (str)
  @string = str
  @values = Version.parse @string
end
usable?() click to toggle source
# File lib/ec2/platform/linux/tar.rb, line 96
def usable?
   self >= Version.new(Version::RECOMMENDED)
end