Class: Top4R::Item

Inherits:
Object
  • Object
show all
Includes:
ModelMixin
Defined in:
lib/top4r/model/item.rb

Overview

Item Model

Constant Summary collapse

@@ATTRIBUTES =
[:id, :iid, :detail_url, :num_iid, :title, :nick, :type, :cid, 
:seller_cids, :props, :input_pids, :input_str, :desc, :pic_url, :num, :valid_thru, 
:list_time, :delist_time, :stuff_status, :location, :price, :post_fee, :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_imgs, :prop_imgs, :skus, :outer_id, :is_virtual, :is_taobao, 
:is_ex, :is_timing, :videos, :is_3D, :score, :volume, :one_station, :second_kill, 
:auto_fill, :props_name, :violation, :created, :is_prepay, :ww_status, :promoted_service]

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ModelMixin

included

Class Method Details

.attributesObject



65
# File 'lib/top4r/model/item.rb', line 65

def attributes; @@ATTRIBUTES; end

.default_public_fieldsObject



67
68
69
70
71
# File 'lib/top4r/model/item.rb', line 67

def default_public_fields
  ["approve_status", "iid", "num_iid", "title", "nick", "type", "cid", "pic_url", "num", "props", 
    "valid_thru", "list_time", "price", "has_discount", "has_invoice", "has_warranty", 
    "has_showcase", "modified", "delist_time", "postage_id", "seller_cids", "outer_id", "detail_url"]
end

Instance Method Details

#search(q) ⇒ Object



74
75
76
# File 'lib/top4r/model/item.rb', line 74

def search(q)
  @client.items_onsale(q)
end

#unmarshal_other_attrsObject



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/top4r/model/item.rb', line 78

def unmarshal_other_attrs
  @id = @num_iid
  if @location && @location.size > 0
    @location = Location.new(@location)
  else
    @location = nil
  end
  if @item_imgs && @item_imgs.size > 0
    @item_imgs.map {|img| ItemImg.new(img)}
  end
  # if @item_imgs.is_a?(Array) && @item_imgs.size > 0
  #         @item_imgs.map {|img| ItemImg.new(img)}
  #       else
  #         @item_imgs = []
  #       end
  #       if @prop_imgs.is_a?(Array) && @prop_imgs.size > 0
  #         @prop_imgs.map {|img| PropImg.new(img)}
  #       else
  #         @prop_imgs = []
  #       end
  
  self
end