Class: Browser::Chrome

Inherits:
Base
  • Object
show all
Defined in:
lib/browser/chrome.rb

Direct Known Subclasses

GoogleSearchApp, SamsungBrowser

Instance Attribute Summary

Attributes inherited from Base

#ua

Instance Method Summary collapse

Methods inherited from Base

#accept_language, #alipay?, #bot, #bot?, #chrome?, #compatibility_view?, #core_media?, #device, #duck_duck_go?, #edge?, #electron?, #facebook?, #firefox?, #google_search_app?, #huawei_browser?, #ie?, #initialize, #instagram?, #known?, #maxthon?, #meta, #micro_messenger?, #miui_browser?, #msie_full_version, #msie_version, #nokia?, #opera?, #opera_mini?, #otter?, #phantom_js?, #platform, #proxy?, #qq?, #quicktime?, #safari?, #safari_webapp_mode?, #samsung_browser?, #snapchat?, #sougou_browser?, #sputnik?, #to_s, #uc_browser?, #unknown?, #version, #webkit?, #webkit_full_version, #weibo?, #yandex?

Constructor Details

This class inherits a constructor from Browser::Base

Instance Method Details

#full_versionObject



13
14
15
16
17
18
19
20
# File 'lib/browser/chrome.rb', line 13

def full_version
  # Each regex on its own line to enforce precedence.
  ua[%r{Chrome/([\d.]+)}, 1] ||
    ua[%r{CriOS/([\d.]+)}, 1] ||
    ua[%r{Safari/([\d.]+)}, 1] ||
    ua[%r{AppleWebKit/([\d.]+)}, 1] ||
    "0.0"
end

#idObject



5
6
7
# File 'lib/browser/chrome.rb', line 5

def id
  :chrome
end

#match?Boolean

Returns:

  • (Boolean)


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/browser/chrome.rb', line 22

def match?
  ua.match?(/Chrome|CriOS/) &&
    !ua.match?(/PhantomJS|FxiOS|ArchiveBot/) &&
    !opera? &&
    !edge? &&
    !duck_duck_go? &&
    !yandex? &&
    !sputnik? &&
    !samsung_browser? &&
    !huawei_browser? &&
    !miui_browser? &&
    !maxthon? &&
    !qq? &&
    !sougou_browser? &&
    !google_search_app?
end

#nameObject



9
10
11
# File 'lib/browser/chrome.rb', line 9

def name
  "Chrome"
end