Class: EBSCO::EDS::Options
- Inherits:
-
Object
- Object
- EBSCO::EDS::Options
- Includes:
- JSONable
- Defined in:
- lib/ebsco/eds/options.rb
Instance Attribute Summary collapse
-
#Actions ⇒ Object
Returns the value of attribute Actions.
-
#Comment ⇒ Object
Returns the value of attribute Comment.
-
#RetrievalCriteria ⇒ Object
Returns the value of attribute RetrievalCriteria.
-
#SearchCriteria ⇒ Object
Returns the value of attribute SearchCriteria.
Instance Method Summary collapse
- #add_actions(actions, info) ⇒ Object
-
#initialize(options = {}, info) ⇒ Options
constructor
A new instance of Options.
-
#to_query_string ⇒ Object
Caution: experimental, not ready for production query-1=AND,volcano&sort=relevance&includefacets=y&searchmode=all&autosuggest=n&view=brief&resultsperpage=20&pagenumber=1&highlight=y.
Methods included from JSONable
Constructor Details
#initialize(options = {}, info) ⇒ Options
Returns a new instance of Options.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/ebsco/eds/options.rb', line 10 def initialize( = {}, info) @SearchCriteria = EBSCO::EDS::SearchCriteria.new(, info) @RetrievalCriteria = EBSCO::EDS::RetrievalCriteria.new(, info) @Actions = [] @Comment = '' # add DefaultOn=y Type=select limiters # info.available_limiters.each do |limiter| # if limiter['DefaultOn'] == 'n' and limiter['Type'] == 'select' # @Actions.push "addLimiter(#{limiter['Id']}:y)" # end # end # add page default of 1 unless .has_key?('page') || .has_key?('page_number') ['page'] = 1 end .each do |key, value| case key when :actions add_actions([:actions], info) # SOLR: Need to add page actions whenever other actions are present since the other actions # will always reset the page to 1 even though a PageNumber is present in RetrievalCriteria. when 'page', 'page_number' @Actions.push "GoToPage(#{value.to_i})" end end end |
Instance Attribute Details
#Actions ⇒ Object
Returns the value of attribute Actions.
9 10 11 |
# File 'lib/ebsco/eds/options.rb', line 9 def Actions @Actions end |
#Comment ⇒ Object
Returns the value of attribute Comment.
9 10 11 |
# File 'lib/ebsco/eds/options.rb', line 9 def Comment @Comment end |
#RetrievalCriteria ⇒ Object
Returns the value of attribute RetrievalCriteria.
9 10 11 |
# File 'lib/ebsco/eds/options.rb', line 9 def RetrievalCriteria @RetrievalCriteria end |
#SearchCriteria ⇒ Object
Returns the value of attribute SearchCriteria.
9 10 11 |
# File 'lib/ebsco/eds/options.rb', line 9 def SearchCriteria @SearchCriteria end |
Instance Method Details
#add_actions(actions, info) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/ebsco/eds/options.rb', line 49 def add_actions(actions, info) if actions.kind_of?(Array) && actions.count > 0 actions.each do |item| #if is_valid_action(item, info) @Actions.push item #end end else #if is_valid_action(actions, info) @Actions = [actions] #else #end end end |
#to_query_string ⇒ Object
Caution: experimental, not ready for production query-1=AND,volcano&sort=relevance&includefacets=y&searchmode=all&autosuggest=n&view=brief&resultsperpage=20&pagenumber=1&highlight=y
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/ebsco/eds/options.rb', line 85 def to_query_string qs = '' # SEARCH CRITERIA: # query # if @SearchCriteria.Queries[0].has_key? :BooleanOperator # qs << 'query=' + @SearchCriteria.Queries[0][:BooleanOperator] # else # qs << 'query=AND' # end # if @SearchCriteria.Queries[0].has_key? :FieldCode # qs << ',' + @SearchCriteria.Queries[0][:FieldCode] # end qs << 'query=' + @SearchCriteria.Queries[0][:Term] # mode qs << '&searchmode=' + @SearchCriteria.SearchMode # facets qs << '&includefacets=' + @SearchCriteria.IncludeFacets # sort qs << '&sort=' + @SearchCriteria.Sort # auto-suggest qs << '&autosuggest=' + @SearchCriteria.AutoSuggest # auto-correct qs << '&autocorrect=' + @SearchCriteria.AutoCorrect # limiters unless @SearchCriteria.Limiters.nil? qs << '&limiter=' + @SearchCriteria.Limiters.join(',') end # expanders qs << '&expander=' + @SearchCriteria.Expanders.join(',') # facet filters unless @SearchCriteria.FacetFilters.nil? qs << '&facetfilter=1,' + @SearchCriteria.FacetFilters.join(',') end # related content unless @SearchCriteria.RelatedContent.nil? qs << '&relatedcontent=' + @SearchCriteria.RelatedContent.join(',') end # Retrieval Criteria unless @RetrievalCriteria.View.nil? qs << '&view=' + @RetrievalCriteria.View end unless @RetrievalCriteria.ResultsPerPage.nil? qs << '&resultsperpage=' + @RetrievalCriteria.ResultsPerPage.to_s end unless @RetrievalCriteria.PageNumber.nil? qs << '&pagenumber=' + @RetrievalCriteria.PageNumber.to_s end unless @RetrievalCriteria.Highlight.nil? qs << '&highlight=' + @RetrievalCriteria.Highlight.to_s end unless @Actions.nil? @Actions.each do |action| qs << '&action=' + action end end qs end |