Class: LighterpackParser::Category
- Inherits:
-
Object
- Object
- LighterpackParser::Category
- Defined in:
- lib/lighterpack_parser/category.rb
Overview
Represents a category from a Lighterpack list.
Instance Attribute Summary collapse
-
#description ⇒ String?
readonly
Optional description of the category.
-
#items ⇒ Array<Item>
readonly
Array of items in this category.
-
#name ⇒ String
readonly
The name of the category.
Instance Method Summary collapse
-
#initialize(name:, description: nil, items: []) ⇒ Category
constructor
A new instance of Category.
-
#to_h ⇒ Hash
Convert to hash for backward compatibility.
Constructor Details
#initialize(name:, description: nil, items: []) ⇒ Category
Returns a new instance of Category.
15 16 17 18 19 |
# File 'lib/lighterpack_parser/category.rb', line 15 def initialize(name:, description: nil, items: []) @name = name @description = description @items = items end |
Instance Attribute Details
#description ⇒ String? (readonly)
Optional description of the category
9 10 11 |
# File 'lib/lighterpack_parser/category.rb', line 9 def description @description end |
#items ⇒ Array<Item> (readonly)
Array of items in this category
9 10 11 |
# File 'lib/lighterpack_parser/category.rb', line 9 def items @items end |
#name ⇒ String (readonly)
The name of the category
9 10 11 |
# File 'lib/lighterpack_parser/category.rb', line 9 def name @name end |
Instance Method Details
#to_h ⇒ Hash
Convert to hash for backward compatibility
23 24 25 26 27 28 29 |
# File 'lib/lighterpack_parser/category.rb', line 23 def to_h { name: name, description: description, items: items.map(&:to_h) } end |