Module: UserAgent::Browsers::Webkit

Defined in:
lib/user_agent/browsers/webkit.rb

Constant Summary collapse

BuildVersions =
{
  "85.7" => "1.0",
  "85.8.5" => "1.0.3",
  "85.8.2" => "1.0.3",
  "124" => "1.2",
  "125.2" => "1.2.2",
  "125.4" => "1.2.3",
  "125.5.5" => "1.2.4",
  "125.5.6" => "1.2.4",
  "125.5.7" => "1.2.4",
  "312.1.1" => "1.3",
  "312.1" => "1.3",
  "312.5" => "1.3.1",
  "312.5.1" => "1.3.1",
  "312.5.2" => "1.3.1",
  "312.8" => "1.3.2",
  "312.8.1" => "1.3.2",
  "412" => "2.0",
  "412.6" => "2.0",
  "412.6.2" => "2.0",
  "412.7" => "2.0.1",
  "416.11" => "2.0.2",
  "416.12" => "2.0.2",
  "417.9" => "2.0.3",
  "418" => "2.0.3",
  "418.8" => "2.0.4",
  "418.9" => "2.0.4",
  "418.9.1" => "2.0.4",
  "419" => "2.0.4",
  "425.13" => "2.2"
}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extend?(agent) ⇒ Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/user_agent/browsers/webkit.rb', line 4

def self.extend?(agent)
  agent.detect { |useragent| useragent.product == "Safari" || useragent.product == "Chrome" }
end

Instance Method Details

#browserObject



8
9
10
11
12
13
14
# File 'lib/user_agent/browsers/webkit.rb', line 8

def browser
  if detect_product("Chrome")
    "Chrome"
  else
    "Safari"
  end
end

#buildObject



16
17
18
# File 'lib/user_agent/browsers/webkit.rb', line 16

def build
  webkit.version
end

#localizationObject



81
82
83
# File 'lib/user_agent/browsers/webkit.rb', line 81

def localization
  application.comment[3]
end

#osObject



77
78
79
# File 'lib/user_agent/browsers/webkit.rb', line 77

def os
  OperatingSystems.normalize_os(application.comment[2])
end

#platformObject



65
66
67
# File 'lib/user_agent/browsers/webkit.rb', line 65

def platform
  application.comment[0]
end

#securityObject



73
74
75
# File 'lib/user_agent/browsers/webkit.rb', line 73

def security
  Security[application.comment[1]]
end

#versionObject

Prior to Safari 3, the user agent did not include a version number



53
54
55
56
57
58
59
60
61
62
63
# File 'lib/user_agent/browsers/webkit.rb', line 53

def version
  if browser == "Chrome"
    chrome.version
  elsif os =~ /CPU (?:iPhone |iPod )?OS ([\d_]+) like Mac OS X/
    $1.gsub(/_/, '.')
  elsif product = detect_product("Version")
    product.version
  else
    BuildVersions[build]
  end
end

#webkitObject



69
70
71
# File 'lib/user_agent/browsers/webkit.rb', line 69

def webkit
  detect { |useragent| useragent.product == "AppleWebKit" }
end