Class: Taobao::Category
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
-
#initialize(category_id) ⇒ Category
constructor
A new instance of Category.
- #name ⇒ String
- #products ⇒ Taobao::ProductList
- #properties ⇒ Taobao::PropertyList
- #subcategories ⇒ Array<Taobao::Category>
Methods included from Util
Constructor Details
#initialize(category_id) ⇒ Category
Returns a new instance of Category.
6 7 8 |
# File 'lib/taobao/category.rb', line 6 def initialize(category_id) @id = category_id.to_i end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/taobao/category.rb', line 3 def id @id end |
Instance Method Details
#name ⇒ String
11 12 13 |
# File 'lib/taobao/category.rb', line 11 def name @name ||= category_request(cids: @id)[:name] end |
#products ⇒ Taobao::ProductList
31 32 33 |
# File 'lib/taobao/category.rb', line 31 def products @products ||= Taobao::ProductList.new(cid: @id) end |
#properties ⇒ Taobao::PropertyList
26 27 28 |
# File 'lib/taobao/category.rb', line 26 def properties @properties ||= Taobao::PropertyList.new(cid: @id) end |
#subcategories ⇒ Array<Taobao::Category>
16 17 18 19 20 21 22 23 |
# File 'lib/taobao/category.rb', line 16 def subcategories return @subcategories if @subcategories @subcategories = category_request(parent_cid: @id).map do |cat| category = self.class.new cat[:cid] category.to_object(cat) category end end |