Class: WCAPI::GetLocationResponse

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(doc) ⇒ GetLocationResponse

Returns a new instance of GetLocationResponse.



6
7
8
9
10
# File 'lib/wcapi/get_location_response.rb', line 6

def initialize(doc)
  #super doc
  @raw = doc
  parse_holdings(doc)
end

Instance Attribute Details

#institutionsObject

include WCAPI::XPath



4
5
6
# File 'lib/wcapi/get_location_response.rb', line 4

def institutions
  @institutions
end

#rawObject

include WCAPI::XPath



4
5
6
# File 'lib/wcapi/get_location_response.rb', line 4

def raw
  @raw
end

Instance Method Details

#parse_holdings(xml) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/wcapi/get_location_response.rb', line 12

def parse_holdings(xml)
   _oclc_symbol = ""
   _link = ""
   _copies = ""
   _xml = xml
   _instchash = {}
   _records = Array.new()
   _x = 0

   doc = Nokogiri::XML(xml)
   nodes = doc.xpath("//holding")
   nodes.each { |item |
      _oclc_symbol = item.xpath("institutionIdentifier/value[position()=1]").text

	 if item.xpath("electronicAddress/text") != nil
  _link = item.xpath("electronicAddress/text[position()=1]").text
      end
	
	 if item.xpath("holdingSimple/copiesSummary/copiesCount") != nil
  _copies = item.xpath("holdingSimple/copiesSummary/copiesCount[position()=1]").text
	 end 


      _instchash = {:institutionIdentifier => _oclc_symbol, :link => _link, :copies => _copies ,
    :xml => item.to_s}
	_records.push(_instchash)
   }
   @institutions = _records
end