Class: MultiSolr::SolrFilterRange
- Inherits:
-
SolrFilterSimple
- Object
- SolrFilterSimple
- MultiSolr::SolrFilterRange
- Defined in:
- lib/multi_solr/solr_filter_range.rb
Overview
Filter für Bereiche mit von- und bis-Werten
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from SolrFilterSimple
Instance Method Summary collapse
-
#build_solr_query(value) ⇒ Object
Erzeugen des SolR-Query-Strings.
-
#extract_from_to(value) ⇒ Object
Aus dem ‘value’ von und bis extrahieren Params: value: Hash mit from- und to-Werten Beispiel: { ‘from’ => ‘2011-01-01’, ‘to’ => ‘2011-06-01’ } returns: Array mit von und bis [‘2011-01-01’, ‘2011-06-01’].
- #render_value(value, options = nil) ⇒ Object
Methods inherited from SolrFilterSimple
#initialize, #label, #sanitize_value
Constructor Details
This class inherits a constructor from MultiSolr::SolrFilterSimple
Instance Method Details
#build_solr_query(value) ⇒ Object
Erzeugen des SolR-Query-Strings
6 7 8 9 10 |
# File 'lib/multi_solr/solr_filter_range.rb', line 6 def build_solr_query value from, to = extract_from_to value return nil if from.nil? && to.nil? "#{@field_name}:[#{from || '*'} TO #{to || '*'}]" end |
#extract_from_to(value) ⇒ Object
Aus dem ‘value’ von und bis extrahieren Params:
value: Hash mit from- und to-Werten
Beispiel: { 'from' => '2011-01-01', 'to' => '2011-06-01' }
returns: Array mit von und bis [‘2011-01-01’, ‘2011-06-01’]
29 30 31 32 33 34 35 |
# File 'lib/multi_solr/solr_filter_range.rb', line 29 def extract_from_to value return nil if !value.is_a?(Hash) || value.empty? from, to = value["from"], value["to"] from = nil if from=='' to = nil if to=='' [from, to] end |
#render_value(value, options = nil) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/multi_solr/solr_filter_range.rb', line 13 def render_value value, =nil from, to = extract_from_to value return '' if from.nil? && to.nil? s = [] s << "#{I18n.t('von', :default => 'von')} #{from}" unless from.blank? s << "#{I18n.t('bis', :default => 'bis')} #{to}" unless to.blank? s.join(' ') end |