Class: Libis::Services::Primo::Search
- Inherits:
-
Object
- Object
- Libis::Services::Primo::Search
- Includes:
- GenericSearch, RestClient
- Defined in:
- lib/libis/services/primo/search.rb
Instance Attribute Summary
Attributes included from GenericSearch
#base, #host, #index, #num_records, #record_pointer, #session_id, #set_number, #term
Attributes included from RestClient
Instance Method Summary collapse
- #find(term, options = {}) ⇒ Object
-
#initialize(url = 'https://services.libis.be') ⇒ Search
constructor
A new instance of Search.
- #query(query, options = {}) ⇒ Object
Methods included from GenericSearch
Methods included from RestClient
#configure, #get, #post_data, #post_url, #put_data, #put_url
Constructor Details
#initialize(url = 'https://services.libis.be') ⇒ Search
Returns a new instance of Search.
15 16 17 |
# File 'lib/libis/services/primo/search.rb', line 15 def initialize(url = 'https://services.libis.be') configure(url) end |
Instance Method Details
#find(term, options = {}) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/libis/services/primo/search.rb', line 24 def find(term, = {}) max_count = .delete(:max_count) || 100 result = [] while result.size < max_count reply = query(term, .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 = {}) ⇒ Object
19 20 21 22 |
# File 'lib/libis/services/primo/search.rb', line 19 def query(query, = {}) index = .delete(:index) || 'any' get 'search', {query: "#{index}:#{query}"}.merge() end |