Class: Buscape::Base
Instance Method Summary collapse
-
#initialize(application_id, sandbox = false) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(application_id, sandbox = false) ⇒ Base
Returns a new instance of Base.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/buscape/base.rb', line 5 def initialize(application_id, sandbox = false) raise "You need to inform your :application_id" if application_id.nil? @env = (sandbox) ? 'sandbox' : 'bws' @application_id = application_id; @uris = { :categories => "findCategoryList", :products => "findProductList", :ratings => "viewUserRatings", :oferts => "findOfferList", :details => "viewProductDetails" } @params = { :category => "categoryId", :product => "productId", :top_products => "topProducts", :seller => "sellerId" } @data = {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object (private)
32 33 34 35 36 37 38 39 |
# File 'lib/buscape/base.rb', line 32 def method_missing(method, *args, &block) if @uris.map {|v, k| v }.include? method fetch_api(method) else @data.merge!({method => args[0]}) self end end |