Class: DiviningRod::Matchers

Inherits:
Object
  • Object
show all
Defined in:
lib/divining_rod/matchers.rb

Class Method Summary collapse

Class Method Details

.subdomain(pattern, opts = {}) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/divining_rod/matchers.rb', line 13

def subdomain(pattern, opts={})
  Definition.new(opts) { |request|
    if pattern.match(DiviningRod::Utilities.parse_subdomain(request)[0])
      true
    end
  }
end

.ua(pattern, opts = {}) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/divining_rod/matchers.rb', line 5

def ua(pattern, opts = {})
  Definition.new(opts) { |request|
    if pattern.match(request.env['HTTP_USER_AGENT'])
      true
    end
  }
end

.ua_prof(pattern, opts = {}) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/divining_rod/matchers.rb', line 21

def ua_prof(pattern, opts ={})
  Definition.new(opts) {|request|
    if pattern.match(request.env['HTTP_X_WAP_PROFILE'])
      true
    end
  }
end