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", "534.52.7" => "5.1.2" }.freeze
Class Method Summary collapse
Instance Method Summary collapse
- #application ⇒ Object
- #browser ⇒ Object
- #build ⇒ Object
- #localization ⇒ Object
- #os ⇒ Object
- #platform ⇒ Object
- #security ⇒ Object
-
#version ⇒ Object
Prior to Safari 3, the user agent did not include a version number.
- #webkit ⇒ Object
Class Method Details
.extend?(agent) ⇒ Boolean
4 5 6 |
# File 'lib/user_agent/browsers/webkit.rb', line 4 def self.extend?(agent) agent.detect { |useragent| useragent.product == 'AppleWebKit' } end |
Instance Method Details
#application ⇒ Object
68 69 70 |
# File 'lib/user_agent/browsers/webkit.rb', line 68 def application self.reject { |agent| agent.comment.nil? || agent.comment.empty? }.first end |
#browser ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/user_agent/browsers/webkit.rb', line 8 def browser if os =~ /Android/ 'Android' elsif platform == 'BlackBerry' platform else 'Safari' end end |
#build ⇒ Object
18 19 20 |
# File 'lib/user_agent/browsers/webkit.rb', line 18 def build webkit.version end |
#localization ⇒ Object
108 109 110 111 112 113 114 |
# File 'lib/user_agent/browsers/webkit.rb', line 108 def localization if application.nil? nil else application.comment[3] end end |
#os ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/user_agent/browsers/webkit.rb', line 92 def os if application if application.comment[0] =~ /Windows NT/ .normalize_os(application.comment[0]) elsif application.comment[2].nil? .normalize_os(application.comment[1]) elsif application.comment[1] =~ /Android/ .normalize_os(application.comment[1]) else .normalize_os(application.comment[2]) end else nil end end |
#platform ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/user_agent/browsers/webkit.rb', line 72 def platform if application.nil? nil elsif application.comment[0] =~ /Windows/ 'Windows' elsif application.comment[0] == 'BB10' 'BlackBerry' else application.comment[0] end end |
#security ⇒ Object
88 89 90 |
# File 'lib/user_agent/browsers/webkit.rb', line 88 def security Security[application.comment[1]] end |
#version ⇒ Object
Prior to Safari 3, the user agent did not include a version number
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/user_agent/browsers/webkit.rb', line 56 def version str = if os =~ /CPU (?:iPhone |iPod )?OS ([\d_]+) like Mac OS X/ && browser == "Safari" $1.gsub(/_/, '.') elsif product = detect_product('Version') product.version else BuildVersions[build.to_s] end Version.new(str) if str end |
#webkit ⇒ Object
84 85 86 |
# File 'lib/user_agent/browsers/webkit.rb', line 84 def webkit detect { |useragent| useragent.product == "AppleWebKit" } end |