Class: Waves::Matchers::Ext
Instance Method Summary collapse
- #call(request) ⇒ Object
-
#initialize(ext) ⇒ Ext
constructor
A new instance of Ext.
- #test(val, pat) ⇒ Object
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 |