class Libis::Services::Primo::Search
Public Class Methods
new(url = 'https://services.libis.be')
click to toggle source
# File lib/libis/services/primo/search.rb, line 15 def initialize(url = 'https://services.libis.be') configure(url) end
Public Instance Methods
find(term, options = {})
click to toggle source
# File lib/libis/services/primo/search.rb, line 24 def find(term, options = {}) max_count = options.delete(:max_count) || 100 result = [] while result.size < max_count reply = query(term, options.merge(from: result.size + 1)) max_count = [max_count, reply[:count]].min reply[:data].each do |record| next unless result.size < max_count result << record[:display] end end result end
query(query, options = {})
click to toggle source
# File lib/libis/services/primo/search.rb, line 19 def query(query, options = {}) index = options.delete(:index) || 'any' get 'search', {query: "#{index}:#{query}"}.merge(options) end
Protected Instance Methods
result_parser(response)
click to toggle source
# File lib/libis/services/primo/search.rb, line 40 def result_parser(response) JSON.parse(response, symbolize_names: true) end