Sha256: 1e5f4a40402b6e096357e55f67d0559f3f990915dd28f20ea32d6befadb15f9f
Contents?: true
Size: 1.8 KB
Versions: 1
Compression:
Stored size: 1.8 KB
Contents
module Voyager module Holdings class Order attr_reader :orders, :current_issues def initialize(xml_node) serialsCheckIn = xml_node.at_css("mfhd|serialsCheckIn") @current_issues = parse_current_issues(serialsCheckIn) poLineItems = xml_node.at_css("mfhd|poLineItems") @orders = parse_order(poLineItems) end private def parse_current_issues(serialsCheckIn) return [] unless serialsCheckIn current_issues = [] # cannot verify that there can be only one mfhd:recent node serialsCheckIn.css("mfhd|recent").each do |recent| # there can be more than one enumChron per recent node recent.css("mfhd|enumChron").each do |enumChron| current_issues << enumChron.content end end current_issues end def parse_order(poLineItems) return [] unless poLineItems poLineItems.css("mfhd|lineItemStatus").collect { |lineItemStatus| generate_order_message(lineItemStatus) } end def generate_order_message(lineItemStatus) status = lineItemStatus.at_css("mfhd|status").content date = lineItemStatus.at_css("mfhd|date").content message = '' case status when "0" message = "In the Pre-Order Process. Try Borrow Direct or ILL." when "1" message = "Received #{date}. Place an In Process item request." when "4" message = "Not yet received; claimed #{date}. Try Borrow Direct or ILL." when "8" message = "Copy On Order #{date}. Try Borrow Direct or ILL." else message = "Unknown" end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
voyager_api-0.1.0 | lib/holdings/order.rb |