Class: UserAgent::Browsers::Base
- Inherits:
-
Array
- Object
- Array
- UserAgent::Browsers::Base
show all
- Includes:
- Comparable
- Defined in:
- lib/user_agent/browsers/base.rb
Direct Known Subclasses
AppleCoreMedia, Chrome, Edge, Gecko, InternetExplorer, Libavformat, Opera, PlayStation, PodcastAddict, Vivaldi, Webkit, WechatBrowser, WindowsMediaPlayer
Instance Method Summary
collapse
Methods included from Comparable
#<, #<=, #==, #>, #>=
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
51
52
53
|
# File 'lib/user_agent/browsers/base.rb', line 51
def method_missing(method, *args, &block)
detect_product(method) || super
end
|
Instance Method Details
#<=>(other) ⇒ Object
6
7
8
9
10
11
12
13
|
# File 'lib/user_agent/browsers/base.rb', line 6
def <=>(other)
if respond_to?(:browser) && other.respond_to?(:browser) &&
browser == other.browser
version <=> Version.new(other.version)
else
false
end
end
|
#application ⇒ Object
27
28
29
|
# File 'lib/user_agent/browsers/base.rb', line 27
def application
first
end
|
#bot? ⇒ Boolean
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/user_agent/browsers/base.rb', line 67
def bot?
if application.nil?
true
elsif (/bot/i)
true
elsif detect_product("Chrome-Lighthouse")
true
elsif product = application.product
product.include?('bot')
else
false
end
end
|
#browser ⇒ Object
31
32
33
|
# File 'lib/user_agent/browsers/base.rb', line 31
def browser
application && application.product
end
|
#eql?(other) ⇒ Boolean
15
16
17
|
# File 'lib/user_agent/browsers/base.rb', line 15
def eql?(other)
self == other
end
|
#mobile? ⇒ Boolean
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/user_agent/browsers/base.rb', line 55
def mobile?
if detect_product('Mobile') || ('Mobile')
true
elsif os =~ /Android/
true
elsif application && application. { |c| c =~ /^IEMobile/ }
true
else
false
end
end
|
#os ⇒ Object
43
44
45
|
# File 'lib/user_agent/browsers/base.rb', line 43
def os
nil
end
|
39
40
41
|
# File 'lib/user_agent/browsers/base.rb', line 39
def platform
nil
end
|
#respond_to?(symbol, include_all = false) ⇒ Boolean
47
48
49
|
# File 'lib/user_agent/browsers/base.rb', line 47
def respond_to?(symbol, include_all = false)
detect_product(symbol) ? true : super
end
|
#to_h ⇒ Object
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
# File 'lib/user_agent/browsers/base.rb', line 92
def to_h
return unless application
hash = {
:browser => browser,
:platform => platform,
:os => os,
:mobile => mobile?,
:bot => bot?,
}
if version
hash[:version] = version.to_a
else
hash[:version] = nil
end
if = application.
hash[:comment] = .dup
else
hash[:comment] = nil
end
hash
end
|
#to_s ⇒ Object
19
20
21
|
# File 'lib/user_agent/browsers/base.rb', line 19
def to_s
to_str
end
|
#to_str ⇒ Object
23
24
25
|
# File 'lib/user_agent/browsers/base.rb', line 23
def to_str
join(" ")
end
|
#version ⇒ Object
35
36
37
|
# File 'lib/user_agent/browsers/base.rb', line 35
def version
application && application.version
end
|