Class: ProductSpy::Host::Builder
- Inherits:
-
Object
- Object
- ProductSpy::Host::Builder
- Defined in:
- lib/product_spy/host.rb
Instance Method Summary collapse
- #get_url(pk) ⇒ Object
-
#initialize(pattern, &block) ⇒ Builder
constructor
A new instance of Builder.
Constructor Details
#initialize(pattern, &block) ⇒ Builder
Returns a new instance of Builder.
21 22 23 24 |
# File 'lib/product_spy/host.rb', line 21 def initialize(pattern, &block) @pattern = pattern @block = block end |
Instance Method Details
#get_url(pk) ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/product_spy/host.rb', line 26 def get_url(pk) if @block.respond_to?(:call) @block.call(pk) else @pattern.gsub /:(\d+)/ do |i| pk[i[1..-1].to_i-1] end end end |