Class: Ovto::Router::SimpleMatcher

Inherits:
Matcher
  • Object
show all
Defined in:
lib/ovto/router/matcher.rb

Instance Method Summary collapse

Methods inherited from Matcher

build

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

Returns:

  • (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