Class: CatalogAPI::Category
- Inherits:
-
Object
- Object
- CatalogAPI::Category
- Defined in:
- lib/catalogapi/category.rb
Instance Attribute Summary collapse
-
#category_id ⇒ Object
readonly
Returns the value of attribute category_id.
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#depth ⇒ Object
readonly
Returns the value of attribute depth.
-
#item_count ⇒ Object
readonly
Returns the value of attribute item_count.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#parent_category_id ⇒ Object
readonly
Returns the value of attribute parent_category_id.
Instance Method Summary collapse
-
#initialize(opts) ⇒ Category
constructor
A new instance of Category.
Constructor Details
#initialize(opts) ⇒ Category
Returns a new instance of Category.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/catalogapi/category.rb', line 7 def initialize(opts) @category_id = opts[:category_id] @children = opts.dig(:children, :Category).to_a.map do |child| CatalogAPI::Category.new(child) end @depth = opts[:depth] @item_count = opts[:item_count] @name = opts[:name] @parent_category_id = opts[:parent_category_id] end |
Instance Attribute Details
#category_id ⇒ Object (readonly)
Returns the value of attribute category_id.
5 6 7 |
# File 'lib/catalogapi/category.rb', line 5 def category_id @category_id end |
#children ⇒ Object (readonly)
Returns the value of attribute children.
5 6 7 |
# File 'lib/catalogapi/category.rb', line 5 def children @children end |
#depth ⇒ Object (readonly)
Returns the value of attribute depth.
5 6 7 |
# File 'lib/catalogapi/category.rb', line 5 def depth @depth end |
#item_count ⇒ Object (readonly)
Returns the value of attribute item_count.
5 6 7 |
# File 'lib/catalogapi/category.rb', line 5 def item_count @item_count end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/catalogapi/category.rb', line 5 def name @name end |
#parent_category_id ⇒ Object (readonly)
Returns the value of attribute parent_category_id.
5 6 7 |
# File 'lib/catalogapi/category.rb', line 5 def parent_category_id @parent_category_id end |