Class: Taobao::Product
- Inherits:
-
Object
- Object
- Taobao::Product
- Defined in:
- lib/taobao/product.rb
Constant Summary collapse
- BASIC_PROPERTIES =
[:cid, :num_iid, :title, :nick, :price, :pic_url, :type, :score, :delist_time, :post_fee, :volume]
- OTHER_PROPERTIES =
[:detail_url, :seller_cids, :props, :input_pids, :input_str, :desc, :num, :valid_thru, :list_time, :stuff_status, :location, :express_fee, :ems_fee, :has_discount, :freight_payer, :has_invoice, :has_warranty, :has_showcase, :modified, :increment, :approve_status, :postage_id, :product_id, :auction_point, :property_alias, :item_img, :prop_img, :sku, :video, :outer_id, :is_virtual]
Instance Method Summary collapse
-
#initialize(product_properties) ⇒ Product
constructor
A new instance of Product.
- #method_missing(method_name, *args, &block) ⇒ Object
- #user ⇒ Object
Constructor Details
#initialize(product_properties) ⇒ Product
Returns a new instance of Product.
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/taobao/product.rb', line 16 def initialize(product_properties) @all_properties_fetched = false @properties = [] if Hash === product_properties hash_to_object(product_properties) else @num_iid = product_properties.to_s fetch_full_data convert_data_types end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/taobao/product.rb', line 33 def method_missing(method_name, *args, &block) if @properties.include? method_name fetch_full_data unless @all_properties_fetched self.instance_variable_get "@#{method_name}" else super end end |