Class: Eldr::Matcher
- Inherits:
-
Object
- Object
- Eldr::Matcher
- Defined in:
- lib/eldr/matcher.rb
Instance Method Summary collapse
- #handler ⇒ Object
-
#initialize(path, options = {}) ⇒ Matcher
constructor
A new instance of Matcher.
- #match(pattern) ⇒ Object
Constructor Details
#initialize(path, options = {}) ⇒ Matcher
Returns a new instance of Matcher.
5 6 7 8 |
# File 'lib/eldr/matcher.rb', line 5 def initialize(path, = {}) @path = path @capture = .delete(:capture) end |
Instance Method Details
#handler ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/eldr/matcher.rb', line 14 def handler @handler ||= case @path when String Mustermann.new(@path, capture: @capture) when Regexp /^(?:#{@path})$/ end end |
#match(pattern) ⇒ Object
10 11 12 |
# File 'lib/eldr/matcher.rb', line 10 def match(pattern) handler.match(pattern) end |