Class: Rack::Forwarder::Registry::Matcher
- Inherits:
-
Struct
- Object
- Struct
- Rack::Forwarder::Registry::Matcher
- Defined in:
- lib/rack/forwarder/matcher.rb
Instance Attribute Summary collapse
-
#regexp ⇒ Object
Returns the value of attribute regexp.
-
#to ⇒ Object
Returns the value of attribute to.
Instance Method Summary collapse
Instance Attribute Details
#regexp ⇒ Object
Returns the value of attribute regexp
4 5 6 |
# File 'lib/rack/forwarder/matcher.rb', line 4 def regexp @regexp end |
#to ⇒ Object
Returns the value of attribute to
4 5 6 |
# File 'lib/rack/forwarder/matcher.rb', line 4 def to @to end |
Instance Method Details
#match?(path) ⇒ Boolean
5 6 7 |
# File 'lib/rack/forwarder/matcher.rb', line 5 def match?(path) regexp =~ path end |
#url_from(path) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/rack/forwarder/matcher.rb', line 9 def url_from(path) return URI.join(to, path).to_s unless to =~ /\$\d+/ regexp.match(path).captures.to_enum .with_index(1).each_with_object(to) do |(match, index), url| url.gsub!("$#{index}", match) end end |