Class: Reynard::Template
- Inherits:
-
Object
- Object
- Reynard::Template
- Defined in:
- lib/reynard/template.rb
Overview
Basic implementation of URI templates.
See: RFC6570
Constant Summary collapse
- VARIABLE_RE =
/\{([^}]+)\}/
Instance Method Summary collapse
-
#initialize(template, params) ⇒ Template
constructor
A new instance of Template.
- #result ⇒ Object
Constructor Details
#initialize(template, params) ⇒ Template
Returns a new instance of Template.
10 11 12 13 |
# File 'lib/reynard/template.rb', line 10 def initialize(template, params) @template = template @params = params end |
Instance Method Details
#result ⇒ Object
15 16 17 18 19 |
# File 'lib/reynard/template.rb', line 15 def result @template.gsub(VARIABLE_RE) do Rack::Utils.escape_path(@params.fetch(Regexp.last_match(1)).to_s) end end |