Class: Holding
- Inherits:
-
Object
- Object
- Holding
- Defined in:
- lib/holding.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#identifier ⇒ Object
Returns the value of attribute identifier.
-
#locations ⇒ Object
Returns the value of attribute locations.
Instance Method Summary collapse
- #find_item_by_attribute(key, value) ⇒ Object
- #find_location(location) ⇒ Object
-
#initialize ⇒ Holding
constructor
A new instance of Holding.
Constructor Details
#initialize ⇒ Holding
Returns a new instance of Holding.
3 4 5 |
# File 'lib/holding.rb', line 3 def initialize @locations = [] end |
Instance Attribute Details
#identifier ⇒ Object
Returns the value of attribute identifier.
2 3 4 |
# File 'lib/holding.rb', line 2 def identifier @identifier end |
#locations ⇒ Object
Returns the value of attribute locations.
2 3 4 |
# File 'lib/holding.rb', line 2 def locations @locations end |
Instance Method Details
#find_item_by_attribute(key, value) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/holding.rb', line 13 def find_item_by_attribute(key, value) @locations.each do | loc | loc.items.each do | item | return if item.instance_variable_get('@'+key) == value end end return nil end |
#find_location(location) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/holding.rb', line 6 def find_location(location) @locations.each do | loc | return loc if loc.name == location end return nil end |