Class: UserAgent::Browsers::Chrome
- Inherits:
-
Base
- Object
- Array
- Base
- UserAgent::Browsers::Chrome
show all
- Defined in:
- lib/user_agent/browsers/chrome.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#<=>, #bot?, #eql?, #method_missing, #mobile?, #respond_to?, #to_h, #to_s, #to_str
Methods included from Comparable
#<, #<=, #==, #>, #>=
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class UserAgent::Browsers::Base
Class Method Details
.extend?(agent) ⇒ Boolean
4
5
6
7
8
|
# File 'lib/user_agent/browsers/chrome.rb', line 4
def self.extend?(agent)
agent.detect { |useragent|
%w(Chrome CriOS).include?(useragent.product)
}
end
|
Instance Method Details
#application ⇒ Object
29
30
31
|
# File 'lib/user_agent/browsers/chrome.rb', line 29
def application
self.reject { |agent| agent..nil? || agent..empty? }.first
end
|
#browser ⇒ Object
10
11
12
|
# File 'lib/user_agent/browsers/chrome.rb', line 10
def browser
'Chrome'
end
|
#build ⇒ Object
14
15
16
|
# File 'lib/user_agent/browsers/chrome.rb', line 14
def build
webkit.version
end
|
#localization ⇒ Object
67
68
69
70
71
72
73
|
# File 'lib/user_agent/browsers/chrome.rb', line 67
def localization
if application.nil?
nil
else
application.[3]
end
end
|
#os ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/user_agent/browsers/chrome.rb', line 51
def os
if application
if application.[0] =~ /Windows NT/
OperatingSystems.normalize_os(application.[0])
elsif application.[2].nil?
OperatingSystems.normalize_os(application.[1])
elsif application.[1] =~ /Android/
OperatingSystems.normalize_os(application.[1])
else
OperatingSystems.normalize_os(application.[2])
end
else
nil
end
end
|
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/user_agent/browsers/chrome.rb', line 33
def platform
if application.nil?
nil
elsif application.[0] =~ /Windows/
'Windows'
elsif application..any? { |c| c =~ /CrOS/ }
'ChromeOS'
elsif application..any? { |c| c =~ /Android/ }
'Android'
else
application.[0]
end
end
|
#version ⇒ Object
Prior to Safari 3, the user agent did not include a version number
19
20
21
22
23
24
25
26
27
|
# File 'lib/user_agent/browsers/chrome.rb', line 19
def version
str = if detect_product("CriOs")
crios.version
else
chrome.version
end
Version.new(str)
end
|
#webkit ⇒ Object
47
48
49
|
# File 'lib/user_agent/browsers/chrome.rb', line 47
def webkit
detect { |useragent| useragent.product == "AppleWebKit" }
end
|