Class: DeviceDetector::ClientHint
- Inherits:
-
Object
- Object
- DeviceDetector::ClientHint
- Defined in:
- lib/device_detector/client_hint.rb
Defined Under Namespace
Classes: HintBrowser
Constant Summary collapse
- ROOT =
File.('../..', __dir__)
Instance Attribute Summary collapse
-
#app_name ⇒ Object
readonly
Returns the value of attribute app_name.
-
#browser_list ⇒ Object
readonly
Returns the value of attribute browser_list.
-
#full_version ⇒ Object
readonly
Returns the value of attribute full_version.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#mobile ⇒ Object
readonly
Returns the value of attribute mobile.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#platform ⇒ Object
readonly
Returns the value of attribute platform.
-
#platform_version ⇒ Object
readonly
Returns the value of attribute platform_version.
Instance Method Summary collapse
- #browser_name ⇒ Object
-
#initialize(headers) ⇒ ClientHint
constructor
A new instance of ClientHint.
- #os_family ⇒ Object
- #os_name ⇒ Object
- #os_short_name ⇒ Object
- #os_version ⇒ Object
Constructor Details
#initialize(headers) ⇒ ClientHint
Returns a new instance of ClientHint.
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/device_detector/client_hint.rb', line 13 def initialize(headers) return if headers.nil? @headers = headers @full_version = headers['Sec-CH-UA-Full-Version'] @browser_list = extract_browser_list @app_name = extract_app_name @platform = headers['Sec-CH-UA-Platform'] @platform_version = extract_platform_version @mobile = headers['Sec-CH-UA-Mobile'] @model = extract_model end |
Instance Attribute Details
#app_name ⇒ Object (readonly)
Returns the value of attribute app_name.
26 27 28 |
# File 'lib/device_detector/client_hint.rb', line 26 def app_name @app_name end |
#browser_list ⇒ Object (readonly)
Returns the value of attribute browser_list.
26 27 28 |
# File 'lib/device_detector/client_hint.rb', line 26 def browser_list @browser_list end |
#full_version ⇒ Object (readonly)
Returns the value of attribute full_version.
26 27 28 |
# File 'lib/device_detector/client_hint.rb', line 26 def full_version @full_version end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
26 27 28 |
# File 'lib/device_detector/client_hint.rb', line 26 def headers @headers end |
#mobile ⇒ Object (readonly)
Returns the value of attribute mobile.
26 27 28 |
# File 'lib/device_detector/client_hint.rb', line 26 def mobile @mobile end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
26 27 28 |
# File 'lib/device_detector/client_hint.rb', line 26 def model @model end |
#platform ⇒ Object (readonly)
Returns the value of attribute platform.
26 27 28 |
# File 'lib/device_detector/client_hint.rb', line 26 def platform @platform end |
#platform_version ⇒ Object (readonly)
Returns the value of attribute platform_version.
26 27 28 |
# File 'lib/device_detector/client_hint.rb', line 26 def platform_version @platform_version end |
Instance Method Details
#browser_name ⇒ Object
29 30 31 32 33 |
# File 'lib/device_detector/client_hint.rb', line 29 def browser_name return 'Iridium' if is_iridium? browser_name_from_list || app_name end |
#os_family ⇒ Object
54 55 56 57 58 |
# File 'lib/device_detector/client_hint.rb', line 54 def os_family return if os_short_name.nil? DeviceDetector::OS::FAMILY_TO_OS[os_short_name] end |
#os_name ⇒ Object
41 42 43 44 45 46 |
# File 'lib/device_detector/client_hint.rb', line 41 def os_name return 'Android' if android_app? return unless ['Windows', 'Chromium OS'].include?(platform) platform end |
#os_short_name ⇒ Object
48 49 50 51 52 |
# File 'lib/device_detector/client_hint.rb', line 48 def os_short_name return if os_name.nil? DeviceDetector::OS::DOWNCASED_OPERATING_SYSTEMS[os_name.downcase] end |
#os_version ⇒ Object
35 36 37 38 39 |
# File 'lib/device_detector/client_hint.rb', line 35 def os_version return windows_version if platform == 'Windows' platform_version end |