class EvergreenHoldings::Status
Status
objects represent all the holdings attached to a specific tcn
Attributes
copies[R]
libraries[R]
Public Class Methods
new(json_data, idl_order, connection = nil)
click to toggle source
# File lib/evergreen_holdings.rb, line 157 def initialize(json_data, idl_order, connection = nil) @idl_order = idl_order @connection = connection @raw_data = JSON.parse(json_data)['payload'][0] extract_copies substitute_values_for_ids unless @connection.nil? @available_copies = [] @next_copy_available = 'a date' end
Public Instance Methods
any_copies_available?()
click to toggle source
Determines if any copies are available for your patrons
# File lib/evergreen_holdings.rb, line 168 def any_copies_available? @copies.each do |copy| return true if copy.status.zero? return true if copy.status == 'Available' end false end
Private Instance Methods
extract_copies()
click to toggle source
Look through @raw_data and find the copies
# File lib/evergreen_holdings.rb, line 179 def extract_copies @copies = [] @raw_data.each do |vol| next if vol['__p'][0].empty? vol['__p'][0].each do |item| item_info = { barcode: item['__p'][@idl_order[:acp]['barcode']], call_number: vol['__p'][@idl_order[:acn]['label']], location: item['__p'][@idl_order[:acp]['location']], status: item['__p'][@idl_order[:acp]['status']], owning_lib: item['__p'][@idl_order[:acp]['circ_lib']] } if item['__p'][@idl_order[:acp]['circulations']].is_a? Array begin item_info[:due_date] = item['__p'][@idl_order[:acp]['circulations']][0]['__p'][@idl_order[:circ]['due_date']] rescue StandardError end @copies.push Item.new item_info else @copies.push Item.new item_info end end end end
substitute_values_for_ids()
click to toggle source
# File lib/evergreen_holdings.rb, line 206 def substitute_values_for_ids @libraries = @connection.org_units.clone @libraries.each { |_key, lib| lib[:copies] = [] } @copies.each do |copy| copy.location = @connection.location_name copy.location if copy.location.is_a? Numeric copy.status = @connection.status_name copy.status if copy.status.is_a? Numeric next unless copy.owning_lib.is_a? Numeric ou_id = copy.owning_lib copy.owning_lib = @connection.ou_name copy.owning_lib @libraries[ou_id][:copies].push copy end end