Class: Browser::Platform::IOS

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

Constant Summary collapse

MATCHER =
/(iPhone|iPad|iPod|CriOS)/.freeze
VERSION_MATCHER =
/OS (?<major>\d+)_(?<minor>\d+)_?(?<patch>\d+)?/.freeze

Instance Attribute Summary

Attributes inherited from Base

#ua

Instance Method Summary collapse

Methods inherited from Base

#accept_language, #alipay?, #bot, #bot?, #chrome?, #chromium_based?, #compatibility_view?, #core_media?, #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?, #webkit?, #webkit_full_version, #weibo?, #yandex?

Constructor Details

This class inherits a constructor from Browser::Base

Instance Method Details

#deviceObject



38
39
40
# File 'lib/browser/platform/ios.rb', line 38

def device
  ua[MATCHER, 1]
end

#idObject



30
31
32
# File 'lib/browser/platform/ios.rb', line 30

def id
  :ios
end

#match?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/browser/platform/ios.rb', line 34

def match?
  ua.match?(MATCHER)
end

#nameObject



26
27
28
# File 'lib/browser/platform/ios.rb', line 26

def name
  "iOS (#{device})"
end

#versionObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/browser/platform/ios.rb', line 10

def version
  matches = VERSION_MATCHER.match(ua)

  return "0" unless matches

  versions = [matches[:major]]

  if matches[:patch]
    versions.push(matches[:minor], matches[:patch])
  else
    versions.push(matches[:minor]) unless matches[:minor] == "0"
  end

  versions.join(".")
end