circleci
418 of 418 new or added lines in 20 files covered. (100.0%)
0 of 13071 relevant lines covered (0.0%)
0.0 hits per line
1 |
# frozen_string_literal: true
|
× |
2 |
require 'browser'
|
× |
3 |
|
× |
4 |
class MobileDetector |
× |
5 |
def self.detect(browser) |
× |
6 |
new(browser).detect |
× |
7 |
end
|
× |
8 |
|
× |
9 |
def initialize(browser) |
× |
10 |
@browser = browser
|
× |
11 |
end
|
× |
12 |
|
× |
13 |
def detect |
× |
14 |
{ action_mobile: device }
|
× |
15 |
end
|
× |
16 |
|
× |
17 |
private |
× |
18 |
|
× |
19 |
def device |
× |
20 |
return 'unknown' if @browser.ua.blank? |
× |
21 |
if @browser.device.mobile? |
× |
22 |
'mobile'
|
× |
23 |
elsif @browser.device.tablet? |
× |
24 |
'tablet'
|
× |
25 |
else
|
× |
26 |
'desktop'
|
× |
27 |
end
|
× |
28 |
end
|
× |
29 |
end
|
× |