Class: Service::Client::UrlPattern
- Inherits:
-
Object
- Object
- Service::Client::UrlPattern
- Defined in:
- lib/service-client/url_pattern.rb
Instance Method Summary collapse
- #filled_with(options) ⇒ Object
-
#initialize(pattern) ⇒ UrlPattern
constructor
A new instance of UrlPattern.
- #placeholders ⇒ Object
Constructor Details
#initialize(pattern) ⇒ UrlPattern
Returns a new instance of UrlPattern.
2 3 4 5 6 7 |
# File 'lib/service-client/url_pattern.rb', line 2 def initialize(pattern) @pattern = pattern @pattern.scan(/:([^:]+):/).each do |placeholder| placeholders << placeholder.first.to_sym end end |
Instance Method Details
#filled_with(options) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/service-client/url_pattern.rb', line 9 def filled_with() url = @pattern.clone placeholders.each do |placeholder| url.gsub!(/:#{Regexp.escape(placeholder.to_s)}:/, [placeholder].to_s) end url end |
#placeholders ⇒ Object
17 18 19 |
# File 'lib/service-client/url_pattern.rb', line 17 def placeholders @placeholders ||= [] end |