class Taobao::ProductList
Public Instance Methods
each(&block)
click to toggle source
# File lib/taobao/product_list.rb, line 33 def each(&block) products.each{ |item| block.call item } end
method_missing(method_name, *args, &block)
click to toggle source
Calls superclass method
# File lib/taobao/product_list.rb, line 25 def method_missing(method_name, *args, &block) if (m = /^order_by_(?<field>.+)$/.match method_name) order_by m[:field] else super end end
order_by(field)
click to toggle source
# File lib/taobao/product_list.rb, line 19 def order_by(field) clear_response @opts[:order_by] = field self end
page(num)
click to toggle source
# File lib/taobao/product_list.rb, line 7 def page(num) clear_response @opts[:page_no] = num self end
per_page(num)
click to toggle source
# File lib/taobao/product_list.rb, line 13 def per_page(num) clear_response @opts[:page_size] = num self end
size()
click to toggle source
# File lib/taobao/product_list.rb, line 3 def size products.size end
total_count()
click to toggle source
# File lib/taobao/product_list.rb, line 37 def total_count cached_responce[:items_get_response][:total_results].to_i end
Private Instance Methods
get_products_as_objects(products)
click to toggle source
# File lib/taobao/product_list.rb, line 49 def get_products_as_objects(products) products.map { |product| Taobao::Product.new product } end
products()
click to toggle source
# File lib/taobao/product_list.rb, line 42 def products products = cached_responce[:items_get_response][:items][:item] get_products_as_objects products rescue NoMethodError [] end
retrieve_response()
click to toggle source
# File lib/taobao/product_list.rb, line 53 def retrieve_response fields = [:num_iid, :title, :nick, :pic_url, :cid, :price, :type, :delist_time, :post_fee, :score, :volume].join ',' params = {method: 'taobao.items.get', fields: fields} Taobao.api_request params.merge(@opts) end