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