class Alma::Bib
Attributes
id[RW]
response[RW]
Public Class Methods
find(ids, args)
click to toggle source
# File lib/alma/bib.rb, line 8 def self.find(ids, args) get_bibs(ids, args) end
get_availability(ids, args = {})
click to toggle source
# File lib/alma/bib.rb, line 28 def self.get_availability(ids, args = {}) args.merge!({ expand: "p_avail,e_avail,d_avail" }) bibs = get_bibs(ids, args) Alma::AvailabilityResponse.new(bibs) end
get_bibs(ids, args = {})
click to toggle source
# File lib/alma/bib.rb, line 12 def self.get_bibs(ids, args = {}) response = HTTParty.get( self.bibs_base_path, query: { mms_id: ids_from_array(ids) }.merge(args), headers: headers, timeout: timeout ) if response.code == 200 Alma::BibSet.new(get_body_from(response)) else raise StandardError, get_body_from(response) end end
new(response_body)
click to toggle source
# File lib/alma/bib.rb, line 42 def initialize(response_body) @response = response_body @id = @response["mms_id"].to_s end
Private Class Methods
get_body_from(response)
click to toggle source
# File lib/alma/bib.rb, line 63 def self.get_body_from(response) JSON.parse(response.body) end
ids_from_array(ids)
click to toggle source
# File lib/alma/bib.rb, line 67 def self.ids_from_array(ids) ids.map(&:to_s).map(&:strip).join(",") end
Public Instance Methods
record()
click to toggle source
The raw MARCXML record, converted to a Hash
# File lib/alma/bib.rb, line 48 def record @record ||= XmlSimple.xml_in(response["anies"].first) end
Private Instance Methods
bibs_base_path()
click to toggle source
# File lib/alma/bib.rb, line 55 def bibs_base_path self.class.bibs_base_path end
headers()
click to toggle source
# File lib/alma/bib.rb, line 59 def headers self.class.headers end