Class: Mobvious::Strategies::URL
- Inherits:
-
Object
- Object
- Mobvious::Strategies::URL
- Defined in:
- lib/mobvious/strategies/url.rb
Overview
Mobvious device detection strategy that uses URL pattern matching.
Constant Summary collapse
- MOBILE_PATH_RULES =
Rule set with only one rule for domains that begin with
m.
matching as:mobile
. { /^\w+:\/\/m\./ => :mobile }
Instance Method Summary collapse
-
#get_device_type(request) ⇒ Symbol
Gets device type using URL pattern matching.
-
#initialize(rules = MOBILE_PATH_RULES) ⇒ URL
constructor
Creates a new URL strategy instance.
Constructor Details
#initialize(rules = MOBILE_PATH_RULES) ⇒ URL
Creates a new URL strategy instance.
14 15 16 |
# File 'lib/mobvious/strategies/url.rb', line 14 def initialize(rules = MOBILE_PATH_RULES) @rules = rules end |
Instance Method Details
#get_device_type(request) ⇒ Symbol
Gets device type using URL pattern matching. Returns nil if no match found.
22 23 24 25 26 27 |
# File 'lib/mobvious/strategies/url.rb', line 22 def get_device_type(request) @rules.each do |regex, device_type| return device_type if request.url =~ regex end nil end |