Class: Summon::Query
Instance Attribute Summary collapse
-
#facet_fields ⇒ Object
readonly
Returns the value of attribute facet_fields.
-
#facet_value_filters ⇒ Object
readonly
Returns the value of attribute facet_value_filters.
-
#facet_value_group_filters ⇒ Object
readonly
Returns the value of attribute facet_value_group_filters.
-
#holdings_only_enabled? ⇒ Object
readonly
Returns the value of attribute holdings_only_enabled?.
-
#page_number ⇒ Object
readonly
Returns the value of attribute page_number.
-
#page_size ⇒ Object
readonly
Returns the value of attribute page_size.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#query_string ⇒ Object
readonly
Returns the value of attribute query_string.
-
#range_filters ⇒ Object
readonly
Returns the value of attribute range_filters.
-
#search_terms ⇒ Object
readonly
Returns the value of attribute search_terms.
-
#sorts ⇒ Object
readonly
Returns the value of attribute sorts.
-
#text_filters ⇒ Object
readonly
Returns the value of attribute text_filters.
-
#text_queries ⇒ Object
readonly
Returns the value of attribute text_queries.
Instance Method Summary collapse
Methods inherited from Schema
Instance Attribute Details
#facet_fields ⇒ Object (readonly)
Returns the value of attribute facet_fields.
12 13 14 |
# File 'lib/summon/schema/query.rb', line 12 def facet_fields @facet_fields end |
#facet_value_filters ⇒ Object (readonly)
Returns the value of attribute facet_value_filters.
7 8 9 |
# File 'lib/summon/schema/query.rb', line 7 def facet_value_filters @facet_value_filters end |
#facet_value_group_filters ⇒ Object (readonly)
Returns the value of attribute facet_value_group_filters.
8 9 10 |
# File 'lib/summon/schema/query.rb', line 8 def facet_value_group_filters @facet_value_group_filters end |
#holdings_only_enabled? ⇒ Object (readonly)
Returns the value of attribute holdings_only_enabled?.
15 16 17 |
# File 'lib/summon/schema/query.rb', line 15
def holdings_only_enabled?
@holdings_only_enabled?
end
|
#page_number ⇒ Object (readonly)
Returns the value of attribute page_number.
3 4 5 |
# File 'lib/summon/schema/query.rb', line 3 def page_number @page_number end |
#page_size ⇒ Object (readonly)
Returns the value of attribute page_size.
4 5 6 |
# File 'lib/summon/schema/query.rb', line 4 def page_size @page_size end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
14 15 16 |
# File 'lib/summon/schema/query.rb', line 14 def params @params end |
#query_string ⇒ Object (readonly)
Returns the value of attribute query_string.
6 7 8 |
# File 'lib/summon/schema/query.rb', line 6 def query_string @query_string end |
#range_filters ⇒ Object (readonly)
Returns the value of attribute range_filters.
11 12 13 |
# File 'lib/summon/schema/query.rb', line 11 def range_filters @range_filters end |
#search_terms ⇒ Object (readonly)
Returns the value of attribute search_terms.
5 6 7 |
# File 'lib/summon/schema/query.rb', line 5 def search_terms @search_terms end |
#sorts ⇒ Object (readonly)
Returns the value of attribute sorts.
13 14 15 |
# File 'lib/summon/schema/query.rb', line 13 def sorts @sorts end |
#text_filters ⇒ Object (readonly)
Returns the value of attribute text_filters.
10 11 12 |
# File 'lib/summon/schema/query.rb', line 10 def text_filters @text_filters end |
#text_queries ⇒ Object (readonly)
Returns the value of attribute text_queries.
9 10 11 |
# File 'lib/summon/schema/query.rb', line 9 def text_queries @text_queries end |
Instance Method Details
#date_filter ⇒ Object
35 36 37 38 39 |
# File 'lib/summon/schema/query.rb', line 35 def date_filter range_filters.find {|f| f.field_name == "PublicationDate"}.tap do |this| yield this if this && block_given? end end |
#date_max ⇒ Object
28 29 30 31 32 33 |
# File 'lib/summon/schema/query.rb', line 28 def date_max date_filter do |f| val = f.range.max_value return val == "*" ? nil : val.to_i end end |
#date_min ⇒ Object
21 22 23 24 25 26 |
# File 'lib/summon/schema/query.rb', line 21 def date_min date_filter do |f| val = f.range.min_value return val == "*" ? nil : val.to_i end end |
#sort ⇒ Object
17 18 19 |
# File 'lib/summon/schema/query.rb', line 17 def sort @sorts.first end |
#to_hash ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/summon/schema/query.rb', line 41 def to_hash # {}.tap do |params| # for param in query_string.split("&") do # name, value = param.split("=") # next if value.nil? # name = CGI.une # end # end return {} if query_string.nil? || query_string == "" params = query_string.split("&").inject({}) do |params, param| name, value = param.split("=") next params if value.nil? name = CGI.unescape(name) value = CGI.unescape(value) params.tap do case params[name] when nil params[name] = value when String params[name] = [params[name], value] else params[name] << value end end end end |