Class: Holding

Inherits:
Object
  • Object
show all
Defined in:
lib/holding.rb

Direct Known Subclasses

Hip3::Item

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeHolding

Returns a new instance of Holding.



3
4
5
# File 'lib/holding.rb', line 3

def initialize
  @locations = []
end

Instance Attribute Details

#identifierObject

Returns the value of attribute identifier.



2
3
4
# File 'lib/holding.rb', line 2

def identifier
  @identifier
end

#locationsObject

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