Class: AgentHelpers::Detector
- Inherits:
-
Object
- Object
- AgentHelpers::Detector
- Defined in:
- lib/agent_helpers/detector.rb
Constant Summary collapse
- WINDOWS_VERSIONS =
{ "NT 5.0" => "Windows 2000", "NT 5.01" => "Windows 2000 SP1", "NT 5.1" => "Windows XP", "NT 5.2" => "Windows XP 64bit", "NT 6.0" => "Windows Vista", "NT 6.1" => "Windows 7", "NT 6.2" => "Windows 8", "NT 6.3" => "Windows 8.1" }
- MAC_OSX_VERSIONS =
{ "10.0" => "Cheetah", "10.1" => "Puma", "10.2" => "Juguar", "10.3" => "Panther", "10.4" => "Tiger", "10.5" => "Leopard", "10.6" => "Snow Leopard", "10.7" => "Lion", "10.8" => "Mountain Lion", "10.9" => "Mavericks", "10.10" => "Yosemite" }
Instance Attribute Summary collapse
-
#browser ⇒ Object
readonly
Returns the value of attribute browser.
-
#device ⇒ Object
readonly
Returns the value of attribute device.
-
#os ⇒ Object
readonly
Returns the value of attribute os.
-
#os_title ⇒ Object
readonly
Returns the value of attribute os_title.
-
#os_version ⇒ Object
readonly
Returns the value of attribute os_version.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(args) ⇒ Detector
constructor
A new instance of Detector.
- #version_major ⇒ Object
Constructor Details
#initialize(args) ⇒ Detector
Returns a new instance of Detector.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/agent_helpers/detector.rb', line 29 def initialize(args) @request = args[:request] raise "No request was given." unless @request @env = @request.env @user_agent = @request.user_agent.to_s.downcase.strip raise "No user agent was given." if @user_agent.empty? browsers = [:chrome, :ie, :firefox, :opera, :safari] browsers.each do |browser| __send__("parse_#{browser}") unless @browser end parse_bots unless @browser parse_device end |
Instance Attribute Details
#browser ⇒ Object (readonly)
Returns the value of attribute browser.
2 3 4 |
# File 'lib/agent_helpers/detector.rb', line 2 def browser @browser end |
#device ⇒ Object (readonly)
Returns the value of attribute device.
2 3 4 |
# File 'lib/agent_helpers/detector.rb', line 2 def device @device end |
#os ⇒ Object (readonly)
Returns the value of attribute os.
2 3 4 |
# File 'lib/agent_helpers/detector.rb', line 2 def os @os end |
#os_title ⇒ Object (readonly)
Returns the value of attribute os_title.
2 3 4 |
# File 'lib/agent_helpers/detector.rb', line 2 def os_title @os_title end |
#os_version ⇒ Object (readonly)
Returns the value of attribute os_version.
2 3 4 |
# File 'lib/agent_helpers/detector.rb', line 2 def os_version @os_version end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
2 3 4 |
# File 'lib/agent_helpers/detector.rb', line 2 def title @title end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
2 3 4 |
# File 'lib/agent_helpers/detector.rb', line 2 def version @version end |
Instance Method Details
#version_major ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/agent_helpers/detector.rb', line 45 def version_major if match = version.to_s.match(/^(\d+)/) return match[1].to_i else return nil end end |