Module: Roda::RodaPlugins::PathMatchers::RequestMethods

Defined in:
lib/roda/plugins/path_matchers.rb

Instance Method Summary collapse

Instance Method Details

#match_extension(ext) ⇒ Object

Match when the current segment ends with the given extension. request path end with the extension.



33
34
35
# File 'lib/roda/plugins/path_matchers.rb', line 33

def match_extension(ext)
  match_suffix(".#{ext}")
end

#match_prefix(prefix) ⇒ Object

Match when the current path segment starts with the given prefix.



38
39
40
# File 'lib/roda/plugins/path_matchers.rb', line 38

def match_prefix(prefix)
  consume(self.class.cached_matcher([:prefix, prefix]){/#{prefix}([^\\\/]+)/})
end

#match_suffix(suffix) ⇒ Object

Match when the current path segment ends with the given suffix.



43
44
45
# File 'lib/roda/plugins/path_matchers.rb', line 43

def match_suffix(suffix)
  consume(self.class.cached_matcher([:suffix, suffix]){/([^\\\/]+)#{suffix}/})
end