Class: UaUtils::UserAgent
- Inherits:
-
Object
- Object
- UaUtils::UserAgent
- Defined in:
- lib/ua-utils/user_agent.rb
Overview
The user agent object.
Example
user_agent = UaUtils::UserAgent.new(
'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_5; en-us) AppleWebKit/533.19.4 (KHTML, like Gecko) Version/5.0.3 Safari/533.19.4')
if user_agent.os.tablet?
(... do something for tablet devices ...)
end
if user_agent.os.platform == :ios
render "/ios/show"
end
Instance Attribute Summary collapse
-
#os ⇒ UaUtils::OperatingSystem
readonly
Returns operating system of the user agent.
Instance Method Summary collapse
-
#initialize(user_agent_string) ⇒ UserAgent
constructor
Initializes a user agent for parsing with a given user agent string.
Constructor Details
#initialize(user_agent_string) ⇒ UserAgent
Initializes a user agent for parsing with a given user agent string
24 25 26 |
# File 'lib/ua-utils/user_agent.rb', line 24 def initialize(user_agent_string) @user_agent_string = user_agent_string end |
Instance Attribute Details
#os ⇒ UaUtils::OperatingSystem (readonly)
Returns operating system of the user agent.
30 31 32 |
# File 'lib/ua-utils/user_agent.rb', line 30 def os @os end |