Class Sinatra::Route
In: lib/sinatra/route.rb
Parent: Object

Methods

new   recognize  

Constants

SYMBOL_FIND = /:[a-z_]+/.freeze
PARENTHETICAL_SEGMENT_STRING = "([^\/.,;?]+)".freeze

Attributes

params  [R] 
regex  [R] 

Public Class methods

[Source]

    # File lib/sinatra/route.rb, line 10
10:     def initialize(template)
11:       @template = template.to_s.strip
12:       @default_params = { :format => 'html' }
13:       @params = {}
14:       extract_keys
15:       genereate_route
16:     end

Public Instance methods

[Source]

    # File lib/sinatra/route.rb, line 18
18:     def recognize(path)
19:       @params.clear
20:       
21:       param_values = path.match(@regex).captures.compact rescue nil
22:             
23:       if param_values
24:         keys = @keys.size < param_values.size ? @keys.concat([:format]) : @keys
25:         @params = @default_params.merge(@keys.zip(param_values).to_hash)
26:         true
27:       else
28:         false
29:       end
30:     end

[Validate]