3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/rails_agent_detect.rb', line 3
def self.is_mobile
docomo = "docomo"
softbank = "softbank"
au = "au"
iphone = "iphone"
ipad = "ipad"
android = "anroid"
blackberry = "blackberry"
blackberry5 = "blackberry5"
windowsphone = "windowsphone"
windowsphone7 = "windowsphone7"
windowsphone8 = "windowsphone8"
motorola = "motorola"
symbian = "symbian"
mobile = "mobile"
lg = "lg"
pc = "pc"
default = "default"
user_agent = request.env['HTTP_USER_AGENT'].downcase if request.env['HTTP_USER_AGENT'].present?
if (user_agent.to_s.match(/iphone/) || user_agent.to_s.match(/ipad/) || user_agent.to_s.match(/android/) || user_agent.to_s.match(/blackberry/) || user_agent.to_s.match(/blackberry5/) || user_agent.to_s.match(/windowsphone/) || user_agent.to_s.match(/windowsphone7/) || user_agent.to_s.match(/windowsphone8/) || user_agent.to_s.match(/motorola/) || user_agent.to_s.match(/symbian/))
return true
else
return false
end
end
|