4 attr_reader :path, :vars
6 VALID_FORMATS = %w( xml html )
12 @regex = create_regex_from_path(@path)
16 !(path =~ @regex).nil?
19 def extract_params(path)
20 if matches = path.to_s.scan(@regex).flatten
21 @param_keys.each_with_index do |v, i|
25 vars[:format] = extract_format(path)
31 def extract_format(path)
32 format = File.extname(path)[1..-1]
33 VALID_FORMATS.include?(format) ? format : 'html'
36 def create_regex_from_path(path)
38 path.gsub!(/:(\w+)/) { @param_keys << $1.intern; '([\w\d-]+)' }
39 path.gsub!(/(\/\.)/) { "\#{$1}" }