Module: Webdriver::UserAgent::Devices

Included in:
Driver
Defined in:
lib/webdriver-user-agent/devices.rb

Instance Method Summary collapse

Instance Method Details

#agent_string_for(device) ⇒ Object


18
19
20
21
22
23
# File 'lib/webdriver-user-agent/devices.rb', line 18

def agent_string_for(device)
  device = (device ? device.downcase : :iphone)
  user_agent_string = (device == :random ? random_user_agent : devices[device][:user_agent])
  raise "Unsupported user agent: '#{device}'." unless user_agent_string
  user_agent_string
end

#devicesObject


7
8
9
# File 'lib/webdriver-user-agent/devices.rb', line 7

def devices
  YAML.load_file devices_file
end

#resolution_for(device_name, orientation, user_width, user_height) ⇒ Object


11
12
13
14
15
16
# File 'lib/webdriver-user-agent/devices.rb', line 11

def resolution_for(device_name, orientation, user_width, user_height)
  return [user_width.to_i, user_height.to_i] if ((user_width.to_i + user_height.to_i) > 1)

  device = devices[device_name.downcase][orientation.downcase]
  [device[:width],device[:height]]
end