Class: RocketFuel::OperatingSystem

Inherits:
Object
  • Object
show all
Defined in:
lib/rocket_fuel/operating_system.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(os = nil, version = nil) ⇒ OperatingSystem

Returns a new instance of OperatingSystem.



7
8
9
10
11
12
13
14
15
16
# 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

Instance Attribute Details

#raw_nameObject (readonly)

Returns the value of attribute raw_name.



5
6
7
# File 'lib/rocket_fuel/operating_system.rb', line 5

def raw_name
  @raw_name
end

#versionObject (readonly)

Returns the value of attribute version.



5
6
7
# File 'lib/rocket_fuel/operating_system.rb', line 5

def version
  @version
end

Instance Method Details

#minor_versionObject

strip the patch level



38
39
40
# File 'lib/rocket_fuel/operating_system.rb', line 38

def minor_version
  /\A(\d+\.\d+)/.match(@version)[0]
end

#nameObject

cribbed from Selenium



20
21
22
23
24
25
26
27
28
29
30
31
# 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) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/rocket_fuel/operating_system.rb', line 33

def platform_family?(platform)
  name == platform.to_sym
end