1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
# frozen_string_literal: true
module Browser
class Platform
class IOS < Base
MATCHER = /(iPhone|iPad|iPod)/.freeze
VERSION_MATCHER =
/OS (?<major>\d+)_(?<minor>\d+)_?(?<patch>\d+)?/.freeze
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
def name
"iOS (#{device})"
end
def id
:ios
end
def match?
ua.match?(MATCHER)
end
def device
ua[MATCHER, 1]
end
end
end
end
|