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, region, timeout, users_base_path
Constructor Details
#initialize(response_body) ⇒ Bib
Returns a new instance of Bib.
40 41 42 43 |
# File 'lib/alma/bib.rb', line 40 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.
35 36 37 |
# File 'lib/alma/bib.rb', line 35 def id @id end |
#response ⇒ Object
Returns the value of attribute response.
35 36 37 |
# File 'lib/alma/bib.rb', line 35 def response @response end |
Class Method Details
.find(ids, args) ⇒ Object
6 7 8 |
# File 'lib/alma/bib.rb', line 6 def self.find(ids, args) get_bibs(ids, args) end |
.get_availability(ids, args = {}) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/alma/bib.rb', line 26 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
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/alma/bib.rb', line 10 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 |
Instance Method Details
#record ⇒ Object
The raw MARCXML record, converted to a Hash
46 47 48 |
# File 'lib/alma/bib.rb', line 46 def record @record ||= XmlSimple.xml_in(response['anies'].first) end |