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.



36
37
38
# File 'lib/roda/plugins/path_matchers.rb', line 36

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

#match_prefix(prefix) ⇒ Object

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



41
42
43
# File 'lib/roda/plugins/path_matchers.rb', line 41

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.



46
47
48
# File 'lib/roda/plugins/path_matchers.rb', line 46

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