Class: Ovto::Router::SimpleMatcher
- Defined in:
- lib/ovto/router/matcher.rb
Instance Method Summary collapse
-
#initialize(str) ⇒ SimpleMatcher
constructor
A new instance of SimpleMatcher.
- #match?(path) ⇒ Boolean
- #params(query) ⇒ Object
Methods inherited from Matcher
Constructor Details
#initialize(str) ⇒ SimpleMatcher
Returns a new instance of SimpleMatcher.
14 15 16 |
# File 'lib/ovto/router/matcher.rb', line 14 def initialize(str) @str = str end |
Instance Method Details
#match?(path) ⇒ Boolean
18 19 20 21 22 23 24 25 |
# File 'lib/ovto/router/matcher.rb', line 18 def match?(path) path, query = path.split('?', 2) return unless path == @str return {} unless query params(query) end |
#params(query) ⇒ Object
27 28 29 |
# File 'lib/ovto/router/matcher.rb', line 27 def params(query) query.split('&').map { |kv| kv.split('=') }.to_h end |