Class: Waves::Matchers::Ext

Inherits:
Object show all
Defined in:
lib/waves/matchers/ext.rb

Instance Method Summary collapse

Constructor Details

#initialize(ext) ⇒ Ext

Returns a new instance of Ext.



6
7
8
# File 'lib/waves/matchers/ext.rb', line 6

def initialize( ext )
  @ext = ext
end

Instance Method Details

#call(request) ⇒ Object



10
11
12
# File 'lib/waves/matchers/ext.rb', line 10

def call(request)
  test( request.extension, @ext )
end

#test(val, pat) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/waves/matchers/ext.rb', line 14

def test( val, pat )
  case pat
  when false then val.nil?
  when true, '.*', val then true
  when Symbol, Symbol then val == ".#{pat}"
  when Array then pat.any? { |e| test( val, e ) }
  end
end