Class: RSolrExt::Params
- Inherits:
-
Object
- Object
- RSolrExt::Params
- Defined in:
- lib/rsolr_ext/params.rb
Overview
utility for querying building RSolrExt::Params.escape(‘a string…’) q = RSolrExt::Params.create_fielded_queries(:name=>‘a string…’, :cat=>[:one, :two]) q == [“a string…”, “cat:one”, “cat:two”]
Class Method Summary collapse
- .calculate_start(page, rows) ⇒ Object
- .create_fielded_queries(params, quote = nil) ⇒ Object
- .escape(value, quote = false) ⇒ Object
Class Method Details
.calculate_start(page, rows) ⇒ Object
17 18 19 20 21 |
# File 'lib/rsolr_ext/params.rb', line 17 def self.calculate_start(page, rows) page = page.to_s.to_i-1 page = page < 1 ? 0 : page page * rows.to_i end |
.create_fielded_queries(params, quote = nil) ⇒ Object
11 12 13 14 15 |
# File 'lib/rsolr_ext/params.rb', line 11 def self.create_fielded_queries(params, quote=nil) params.collect do |k,v| v.is_a?(Array) ? v.collect{|vv|%(#{k}:#{escape(vv, quote)})} : "#{k}:#{escape(v, quote)}" end.flatten end |
.escape(value, quote = false) ⇒ Object
7 8 9 |
# File 'lib/rsolr_ext/params.rb', line 7 def self.escape(value, quote=false) quote ? %("#{value}") : value end |