Class: Exlibris::Primo::Search

Inherits:
Object
  • Object
show all
Includes:
ChainGang::Base, ChainGang::Record, ChainGang::Search, Config::Attributes, RequestAttributes, WriteAttributes
Defined in:
lib/exlibris/primo/search.rb

Overview

Search Primo using Exlibris::Primo::Search

search = Search.new.base_url!("http://primo.library.edu").
  add_query_term("Digital divide", "any", "contains")
search.records #=> Array of Primo records
search.facets #=> Array of Primo facets
search.size #=> Total number of records in the search

There are a several configuration setting for the search

search = Search.new.base_url!("http://primo.library.edu").institution!("PRIMO").
  enable_did_u_mean.on_campus.page_size!(20).start_index!(21).add_sort_by("stitle")
    add_query_term("Digital divide", "any", "contains")
search.records #=> Array of Primo records
search.facets #=> Array of Primo facets
search.size #=> Total number of records in the search

Instance Attribute Summary

Attributes included from ChainGang::Record

#record_id

Instance Method Summary collapse

Methods included from WriteAttributes

#initialize, #write_attributes

Methods included from ChainGang::Search

#add_adaptor_location, #add_display_field, #add_language, #add_local_location, #add_location, #add_query_term, #add_remote_location, #add_sort_by, #and, #disable_did_u_mean, #disable_highlighting, #enable_did_u_mean, #enable_highlighting, included, #method_missing, #or, #page_size!, #respond_to?, #start_index!

Methods included from ChainGang::Record

#record_id!

Methods included from ChainGang::Base

#base_url!, #group!, #institution!, #ip!, #logged_in, #logged_out, #off_campus, #on_campus, #pds_handle!

Methods included from Config::Attributes

#availability_statuses, #base_url, #config, #facet_collections, #facet_labels, #facet_resource_types, #facet_top_level, #institution, #institutions, #libraries, #sources

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Exlibris::Primo::ChainGang::Search

Instance Method Details

#did_u_meanObject

Returns “Did U Mean” suggestion for the search.



62
63
64
# File 'lib/exlibris/primo/search.rb', line 62

def did_u_mean
  @did_u_mean ||= search.did_u_mean
end

#facetsObject

Returns the array of Facets from the search.



48
49
50
# File 'lib/exlibris/primo/search.rb', line 48

def facets
  @facets ||= search.facets
end

#recordsObject

Returns the array of Records from the search.



41
42
43
# File 'lib/exlibris/primo/search.rb', line 41

def records
  @records ||= search.records
end

#searchObject

Returns the Response from the search. Not really intended for public consumption.



33
34
35
36
# File 'lib/exlibris/primo/search.rb', line 33

def search
  request.write_attributes request_attributes
  @search ||= request.call
end

#sizeObject

Returns the total number of records from the search



55
56
57
# File 'lib/exlibris/primo/search.rb', line 55

def size
  @size ||= search.size
end