Class: UwCatalog::Location

Inherits:
Object
  • Object
show all
Defined in:
lib/uw_catalog/model/location.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(h = Hash.new) ⇒ Location

Returns a new instance of Location.



6
7
8
9
# File 'lib/uw_catalog/model/location.rb', line 6

def initialize(h=Hash.new)
  @holdings = Array.new
  h.each {|k,v| send("#{k}=",v)}
end

Instance Attribute Details

#holdingsObject

Returns the value of attribute holdings.



4
5
6
# File 'lib/uw_catalog/model/location.rb', line 4

def holdings
  @holdings
end

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/uw_catalog/model/location.rb', line 4

def id
  @id
end

#locationObject

Returns the value of attribute location.



4
5
6
# File 'lib/uw_catalog/model/location.rb', line 4

def location
  @location
end

Instance Method Details

#==(another_loc) ⇒ Object



11
12
13
# File 'lib/uw_catalog/model/location.rb', line 11

def ==(another_loc)
  self.id == another_loc.id
end

#add_holding(holding) ⇒ Object



19
20
21
22
23
24
# File 'lib/uw_catalog/model/location.rb', line 19

def add_holding(holding)
  idx = @holdings.index(holding)
  if idx.nil?
    holdings << holding
  end
end

#display_locationObject



15
16
17
# File 'lib/uw_catalog/model/location.rb', line 15

def display_location
  location
end

#get_holding(holding) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/uw_catalog/model/location.rb', line 26

def get_holding(holding)
  idx = @holdings.index(holding)
  if idx.nil?
    nil
  else
    @holdings.at(idx)
  end
end