Module: UserAgent::Browsers::Webkit

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

Constant Summary collapse

BuildVersions =

TODO: Complete this mapping See: www.useragentstring.com/pages/Safari/

{
  "125.12" => "1.2.4",
  "312.6" => "1.3.2",
  "412.2.2" => "2.0",
  "412.5" => "2.0.1",
  "416.13" => "2.0.2",
  "417.9.3" => "2.0.3",
  "525.13" => "2.2",
  "522.11.3" => "3.0",
  "523.15" => "3.0",
  "523.12.9" => "3.0",
  "522.12.2" => "3.0.1",
  "522.13.1" => "3.0.2",
  "522.15.5" => "3.0.3",
  "523.10" => "3.0.4",
  "523.15" => "3.0.4",
  "523.12" => "3.0.4",
  "523.12.2" => "3.0.4",
  "525.13" => "3.1",
  "525.13.3" => "3.1",
  "525.9" => "3.1",
  "525.17" => "3.1.1",
  "525.9" => "3.1.1",
  "525.20" => "3.1.1",
  "525.18" => "3.1.1",
  "525.21" => "3.1.2",
  "525.26.13" => "3.2",
  "525.26.12" => "3.2",
  "528.1" => "4.0"
  
}.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" }
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
  safari.version
end

#localizationObject



89
90
91
# File 'lib/user_agent/browsers/webkit.rb', line 89

def localization
  application.comment[3]
end

#osObject



85
86
87
# File 'lib/user_agent/browsers/webkit.rb', line 85

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

#platformObject



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

def platform
  application.comment[0]
end

#securityObject



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

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

#versionObject

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



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

def version
  if browser == "Chrome"
    chrome.version
  elsif product = detect_product("Version")
    product.version
  else
    BuildVersions[build]
  end
end

#version=(v) ⇒ Object



65
66
67
68
69
70
71
# File 'lib/user_agent/browsers/webkit.rb', line 65

def version=(v)
  if browser == "Chrome"
    chrome.version = v
  elsif product = detect_product("Version")
    product.version = v
  end
end

#webkitObject



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

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