Class: ItemBase
- Inherits:
-
Object
- Object
- ItemBase
- Defined in:
- lib/item_base.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#twin_name ⇒ Object
Returns the value of attribute twin_name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(block, _parent = nil, _parent_association = nil) ⇒ ItemBase
constructor
A new instance of ItemBase.
Constructor Details
#initialize(block, _parent = nil, _parent_association = nil) ⇒ ItemBase
Returns a new instance of ItemBase.
4 5 6 7 8 |
# File 'lib/item_base.rb', line 4 def initialize(block, _parent = nil, _parent_association = nil) @id = block.id @name = block.content.split(' || ')[0].underscore.singularize @twin_name = block.content.split(' || ')[1]&.underscore&.singularize end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
2 3 4 |
# File 'lib/item_base.rb', line 2 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/item_base.rb', line 2 def name @name end |
#twin_name ⇒ Object
Returns the value of attribute twin_name.
2 3 4 |
# File 'lib/item_base.rb', line 2 def twin_name @twin_name end |
Class Method Details
.all ⇒ Object
10 11 12 |
# File 'lib/item_base.rb', line 10 def self.all ObjectSpace.each_object(self).to_a end |
.find(id) ⇒ Object
14 15 16 |
# File 'lib/item_base.rb', line 14 def self.find(id) all.find { |item| item.id == id } end |