Class: Browser::Platform::IOS

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

Constant Summary collapse

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

Instance Attribute Summary

Attributes inherited from Base

#accept_language, #ua

Instance Method Summary collapse

Methods inherited from Base

#alipay?, #bot, #bot?, #chrome?, #compatibility_view?, #core_media?, #edge?, #electron?, #facebook?, #firefox?, #ie?, #initialize, #instagram?, #known?, #meta, #micro_messenger?, #modern?, #msie_full_version, #msie_version, #nokia?, #opera?, #opera_mini?, #otter?, #phantom_js?, #platform, #proxy?, #quicktime?, #safari?, #safari_webapp_mode?, #snapchat?, #sputnik?, #to_s, #uc_browser?, #webkit?, #webkit_full_version, #weibo?, #yandex?

Constructor Details

This class inherits a constructor from Browser::Base

Instance Method Details

#deviceObject



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

def device
  ua[MATCHER, 1]
end

#idObject



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

def id
  :ios
end

#match?Boolean

Returns:

  • (Boolean)


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

def match?
  ua =~ MATCHER
end

#nameObject



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

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

#versionObject



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

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