Class: UseragentParser::UserAgent
- Inherits:
-
Object
- Object
- UseragentParser::UserAgent
- Defined in:
- lib/useragent_parser/user_agent.rb
Instance Attribute Summary collapse
-
#browser ⇒ Object
readonly
Returns the value of attribute browser.
-
#browser_family ⇒ Object
readonly
Returns the value of attribute browser_family.
-
#browser_major_version ⇒ Object
readonly
Returns the value of attribute browser_major_version.
-
#browser_minor_version ⇒ Object
readonly
Returns the value of attribute browser_minor_version.
-
#browser_patch_version ⇒ Object
readonly
Returns the value of attribute browser_patch_version.
-
#browser_version ⇒ Object
readonly
Returns the value of attribute browser_version.
-
#os ⇒ Object
readonly
Returns the value of attribute os.
-
#os_family ⇒ Object
readonly
Returns the value of attribute os_family.
-
#os_major_version ⇒ Object
readonly
Returns the value of attribute os_major_version.
-
#os_minor_version ⇒ Object
readonly
Returns the value of attribute os_minor_version.
-
#os_patch_version ⇒ Object
readonly
Returns the value of attribute os_patch_version.
-
#os_version(options = {}) ⇒ Object
readonly
Returns the value of attribute os_version.
-
#webmail_client ⇒ Object
readonly
Returns the value of attribute webmail_client.
Instance Method Summary collapse
- #device ⇒ Object
- #email ⇒ Object
- #email_version ⇒ Object
-
#initialize(details = {}) ⇒ UserAgent
constructor
A new instance of UserAgent.
- #is_email? ⇒ Boolean
- #is_mobile? ⇒ Boolean
- #is_spider? ⇒ Boolean
- #os_family_aggregated ⇒ Object
Constructor Details
#initialize(details = {}) ⇒ UserAgent
Returns a new instance of UserAgent.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/useragent_parser/user_agent.rb', line 7 def initialize(details = {}) if user_agent = details['user_agent'] @browser_family = user_agent['family'] || 'Other' @browser_major_version = user_agent['major'] @browser_minor_version = user_agent['minor'] @browser_patch_version = user_agent['patch'] end if os = details['os'] @os_family = os['family'] || 'Other' @os_major_version = os['major'] @os_minor_version = os['minor'] @os_patch_version = os['patch'] end if device = details['device'] @device = device['family'] @is_mobile = device['is_mobile'] @is_spider = device['is_spider'] end if referrer = details['referrer'] @webmail_client = referrer['family'] end end |
Instance Attribute Details
#browser ⇒ Object (readonly)
Returns the value of attribute browser.
3 4 5 |
# File 'lib/useragent_parser/user_agent.rb', line 3 def browser @browser end |
#browser_family ⇒ Object (readonly)
Returns the value of attribute browser_family.
3 4 5 |
# File 'lib/useragent_parser/user_agent.rb', line 3 def browser_family @browser_family end |
#browser_major_version ⇒ Object (readonly)
Returns the value of attribute browser_major_version.
3 4 5 |
# File 'lib/useragent_parser/user_agent.rb', line 3 def browser_major_version @browser_major_version end |
#browser_minor_version ⇒ Object (readonly)
Returns the value of attribute browser_minor_version.
3 4 5 |
# File 'lib/useragent_parser/user_agent.rb', line 3 def browser_minor_version @browser_minor_version end |
#browser_patch_version ⇒ Object (readonly)
Returns the value of attribute browser_patch_version.
3 4 5 |
# File 'lib/useragent_parser/user_agent.rb', line 3 def browser_patch_version @browser_patch_version end |
#browser_version ⇒ Object (readonly)
Returns the value of attribute browser_version.
3 4 5 |
# File 'lib/useragent_parser/user_agent.rb', line 3 def browser_version @browser_version end |
#os ⇒ Object (readonly)
Returns the value of attribute os.
4 5 6 |
# File 'lib/useragent_parser/user_agent.rb', line 4 def os @os end |
#os_family ⇒ Object (readonly)
Returns the value of attribute os_family.
4 5 6 |
# File 'lib/useragent_parser/user_agent.rb', line 4 def os_family @os_family end |
#os_major_version ⇒ Object (readonly)
Returns the value of attribute os_major_version.
4 5 6 |
# File 'lib/useragent_parser/user_agent.rb', line 4 def os_major_version @os_major_version end |
#os_minor_version ⇒ Object (readonly)
Returns the value of attribute os_minor_version.
4 5 6 |
# File 'lib/useragent_parser/user_agent.rb', line 4 def os_minor_version @os_minor_version end |
#os_patch_version ⇒ Object (readonly)
Returns the value of attribute os_patch_version.
4 5 6 |
# File 'lib/useragent_parser/user_agent.rb', line 4 def os_patch_version @os_patch_version end |
#os_version(options = {}) ⇒ Object (readonly)
Returns the value of attribute os_version.
4 5 6 |
# File 'lib/useragent_parser/user_agent.rb', line 4 def os_version @os_version end |
#webmail_client ⇒ Object (readonly)
Returns the value of attribute webmail_client.
5 6 7 |
# File 'lib/useragent_parser/user_agent.rb', line 5 def webmail_client @webmail_client end |
Instance Method Details
#device ⇒ Object
33 34 35 |
# File 'lib/useragent_parser/user_agent.rb', line 33 def device @device end |
#email ⇒ Object
77 78 79 |
# File 'lib/useragent_parser/user_agent.rb', line 77 def email @email ||= email_name end |
#email_version ⇒ Object
81 82 83 |
# File 'lib/useragent_parser/user_agent.rb', line 81 def email_version @email_version ||= email_version_name end |
#is_email? ⇒ Boolean
85 86 87 |
# File 'lib/useragent_parser/user_agent.rb', line 85 def is_email? is_outlook? || is_ios_mail? || is_apple_mail? || is_desktop_email? || is_webmail? end |
#is_mobile? ⇒ Boolean
37 38 39 |
# File 'lib/useragent_parser/user_agent.rb', line 37 def is_mobile? !!@is_mobile end |
#is_spider? ⇒ Boolean
41 42 43 |
# File 'lib/useragent_parser/user_agent.rb', line 41 def is_spider? !!@is_spider end |
#os_family_aggregated ⇒ Object
66 67 68 69 70 71 |
# File 'lib/useragent_parser/user_agent.rb', line 66 def os_family_aggregated case os_family when 'Windows', 'Windows NT' then 'Windows' else os_family end end |