Class: Alma::Bib
- Inherits:
-
Object
- Object
- Alma::Bib
- Extended by:
- ApiDefaults, Forwardable
- Defined in:
- lib/alma/bib.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#response ⇒ Object
Returns the value of attribute response.
Class Method Summary collapse
- .find(ids, args) ⇒ Object
- .get_availability(ids, args = {}) ⇒ Object
- .get_bibs(ids, args = {}) ⇒ Object
Instance Method Summary collapse
-
#initialize(response_body) ⇒ Bib
constructor
A new instance of Bib.
-
#record ⇒ Object
The raw MARCXML record, converted to a Hash.
Methods included from ApiDefaults
apikey, configuration_base_path, items_base_path, region, timeout, users_base_path
Constructor Details
#initialize(response_body) ⇒ Bib
Returns a new instance of Bib.
42 43 44 45 |
# File 'lib/alma/bib.rb', line 42 def initialize(response_body) @response = response_body @id = @response["mms_id"].to_s end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
37 38 39 |
# File 'lib/alma/bib.rb', line 37 def id @id end |
#response ⇒ Object
Returns the value of attribute response.
37 38 39 |
# File 'lib/alma/bib.rb', line 37 def response @response end |
Class Method Details
.find(ids, args) ⇒ Object
8 9 10 |
# File 'lib/alma/bib.rb', line 8 def self.find(ids, args) get_bibs(ids, args) end |
.get_availability(ids, args = {}) ⇒ Object
28 29 30 31 32 33 |
# 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 = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/alma/bib.rb', line 12 def self.get_bibs(ids, args = {}) response = Net.get( self.bibs_base_path, query: { mms_id: ids_from_array(ids) }.merge(args), headers:, timeout: ) if response.code == 200 Alma::BibSet.new(get_body_from(response)) else raise StandardError, get_body_from(response) end end |
Instance Method Details
#record ⇒ Object
The raw MARCXML record, converted to a Hash
48 49 50 |
# File 'lib/alma/bib.rb', line 48 def record @record ||= XmlSimple.xml_in(response["anies"].first) end |