lib/exlibris/aleph/record.rb in exlibris-aleph-0.0.2 vs lib/exlibris/aleph/record.rb in exlibris-aleph-0.1.0

- old
+ new

@@ -1,8 +1,13 @@ module Exlibris module Aleph + # ==Overview + # Provides access to the Aleph Record REST API. class Record < Rest + attr_reader :bib_library, :record_id + + # Creates an instance of Exlibris::Aleph::Record for the given :bib_library and :record_id def initialize(bib_library, record_id, uri) @record_id = record_id raise "Initialization error in #{self.class}. Missing record id." if @record_id.nil? @bib_library = bib_library raise "Initialization error in #{self.class}. Missing bib library." if @bib_library.nil? @@ -16,19 +21,21 @@ end # Returns an XML string representation of a bib. # Every method call refreshes the data from the underlying API. # Raises and exception if there are errors. + # Returns a HTTParty::Response. def bib @response = self.class.get(@uri+ "?view=full") raise "Error getting bib from Aleph REST APIs. #{error}" unless error.nil? return @response end # Returns an array of items. Each item is represented as an HTTParty hash. # Every method call refreshes the data from the underlying API. # Raises an exception if the response is not valid XML or there are errors. + # Returns a HTTParty::Response. def items @items = [] self.class.format :xml # Since we're parsing xml, this will raise an error # if the response isn't xml. @@ -44,9 +51,10 @@ end # Returns an XML string representation of holdings # Every method call refreshes the data from the underlying API. # Raises and exception if there are errors. + # Returns a HTTParty::Response. def holdings @response = self.class.get(@uri+ "/holdings?view=full") raise "Error getting holdings from Aleph REST APIs. #{error}" unless error.nil? return @response end \ No newline at end of file