class RocketFuel::OperatingSystem

Attributes

raw_name[R]
version[R]

Public Class Methods

new(os = nil, version = nil) click to toggle source
# File lib/rocket_fuel/operating_system.rb, line 7
def initialize(os = nil, version = nil)
  @raw_name, @version = os, version
  if @raw_name.nil?
    derive_raw_name
  end

  if @version.nil?
    derive_version
  end
end

Public Instance Methods

minor_version() click to toggle source

strip the patch level

# File lib/rocket_fuel/operating_system.rb, line 38
def minor_version
  /\A(\d+\.\d+)/.match(@version)[0]
end
name() click to toggle source

cribbed from Selenium

# File lib/rocket_fuel/operating_system.rb, line 20
def name
  case @raw_name
  when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
    :windows
  when /darwin|mac os/
    :mac
  when /linux/
    :linux
  when /solaris|bsd/
    :unix
  end
end
platform_family?(platform) click to toggle source
# File lib/rocket_fuel/operating_system.rb, line 33
def platform_family?(platform)
  name == platform.to_sym
end

Protected Instance Methods

derive_raw_name() click to toggle source
# File lib/rocket_fuel/operating_system.rb, line 43
def derive_raw_name
  @raw_name = RbConfig::CONFIG['host_os']
end
derive_version() click to toggle source
# File lib/rocket_fuel/operating_system.rb, line 47
def derive_version
  if platform_family?(:mac)
    @version = `sw_vers -productVersion`.chomp
  end
end