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 = extract_full_version @browser_list = extract_browser_list @app_name = extract_app_name @platform = extract_platform @platform_version = extract_platform_version @mobile = extract_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 34 |
# File 'lib/device_detector/client_hint.rb', line 29 def browser_name return 'Iridium' if iridium? return '360 Secure Browser' if secure_browser? browser_name_from_list || app_name end |
#os_family ⇒ Object
59 60 61 62 63 |
# File 'lib/device_detector/client_hint.rb', line 59 def os_family return if os_short_name.nil? DeviceDetector::OS::FAMILY_TO_OS[os_short_name] end |
#os_name ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/device_detector/client_hint.rb', line 44 def os_name return 'Android' if android_app? return 'Lineage OS' if lineage_os_app? return 'Fire OS' if fire_os_app? return unless ['Windows', 'Chromium OS'].include?(platform) platform end |
#os_short_name ⇒ Object
53 54 55 56 57 |
# File 'lib/device_detector/client_hint.rb', line 53 def os_short_name return if os_name.nil? DeviceDetector::OS::DOWNCASED_OPERATING_SYSTEMS[os_name.downcase] end |
#os_version ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/device_detector/client_hint.rb', line 36 def os_version return windows_version if platform == 'Windows' return lineage_version if lineage_os_app? return fire_os_version if fire_os_app? platform_version end |