Sha256: a5b7e1d654bda775cc3bdb6313d160dcb2e688739042861734f44fa82a2e0ade
Contents?: true
Size: 1.3 KB
Versions: 1
Compression:
Stored size: 1.3 KB
Contents
module Voyager module Holdings class Collection attr_reader :records, :xml DEFAULT_OPAC_URL = "http://bearberry.cc.columbia.edu:7014/vxws/GetHoldingsService" def self.new_from_opac(bibid, url = DEFAULT_OPAC_URL, httpclient = nil) conn = Voyager::Connection.new(:http_client => httpclient) Collection.new(conn.request(url, :bibId => bibid)) end def initialize(raw_xml) @xml = load_and_namespace_xml(raw_xml) parse_xml end def to_hash output = {} output[:records] = @records.collect do |rec| rec.to_hash end output end private def load_and_namespace_xml(raw_xml) xml = Nokogiri::XML(raw_xml) xml.root.add_namespace_definition("hol", "http://www.endinfosys.com/Voyager/holdings") xml.root.add_namespace_definition("mfhd", "http://www.endinfosys.com/Voyager/mfhd") xml.root.add_namespace_definition("item", "http://www.endinfosys.com/Voyager/item") xml.root.add_namespace_definition("slim", "http://www.loc.gov/MARC21/slim") return xml end def parse_xml @records = @xml.css("hol|mfhdCollection>mfhd|mfhdRecord").collect do |record_node| Record.new(record_node) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
voyager_api-0.1.0 | lib/holdings/collection.rb |