class Skala::AlephAdapter::GetUserInterLibraryLoans
Public Instance Methods
call(username, options = {})
click to toggle source
# File lib/skala/aleph_adapter/get_user_inter_library_loans.rb, line 9 def call(username, options = {}) resolved_user_id = resolve_user(username) raw_aleph_response = adapter.restful_api.patron(resolved_user_id).circulationActions.requests.ill.get(view: :brief) if raw_aleph_response.include?("<error>") return nil else self.class::Result.new( inter_library_loans: Nokogiri::XML(raw_aleph_response).xpath("//ill-request").map do |_ill_request| { id: id(_ill_request), due_date: due_date(_ill_request), record: { creator: creator(_ill_request), id: record_id(_ill_request), title: title(_ill_request), year_of_publication: year_of_publication(_ill_request) }, renewable: renewable(_ill_request) } end, source: raw_aleph_response ) end end
Private Instance Methods
creator(element)
click to toggle source
# File lib/skala/aleph_adapter/get_user_inter_library_loans.rb, line 37 def creator(element) element.at_xpath(".//z13-author").try(:content).presence.try(:split, ";").try(:map, &:strip) end
due_date(element)
click to toggle source
# File lib/skala/aleph_adapter/get_user_inter_library_loans.rb, line 45 def due_date(element) if _due_date = element.at_xpath(".//z36-due-date|.//z36h-due-date").try(:content) Date.strptime(_due_date, "%Y%m%d") end end
id(element)
click to toggle source
# File lib/skala/aleph_adapter/get_user_inter_library_loans.rb, line 41 def id(element) element.attr("href")[/[^\/]+\Z/][/\A[^?]+/] end
record_id(element)
click to toggle source
# File lib/skala/aleph_adapter/get_user_inter_library_loans.rb, line 51 def record_id(element) element.at_xpath(".//z410-doc-number").try(:content).presence end
renewable(element)
click to toggle source
# File lib/skala/aleph_adapter/get_user_inter_library_loans.rb, line 55 def renewable(element) element.attr("renew") == "Y" end
title(element)
click to toggle source
# File lib/skala/aleph_adapter/get_user_inter_library_loans.rb, line 59 def title(element) element.at_xpath(".//z13-title").try(:content).presence end
year_of_publication(element)
click to toggle source
# File lib/skala/aleph_adapter/get_user_inter_library_loans.rb, line 63 def year_of_publication(element) element.at_xpath(".//z13-year").try(:content).presence end