Class: Supernova::Condition
- Inherits:
-
Object
- Object
- Supernova::Condition
- Defined in:
- lib/supernova/condition.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
Returns the value of attribute key.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(key, type) ⇒ Condition
constructor
A new instance of Condition.
- #solr_filter_for(value) ⇒ Object
Constructor Details
#initialize(key, type) ⇒ Condition
Returns a new instance of Condition.
4 5 6 7 |
# File 'lib/supernova/condition.rb', line 4 def initialize(key, type) self.key = key self.type = type end |
Instance Attribute Details
#key ⇒ Object
Returns the value of attribute key.
2 3 4 |
# File 'lib/supernova/condition.rb', line 2 def key @key end |
#type ⇒ Object
Returns the value of attribute type.
2 3 4 |
# File 'lib/supernova/condition.rb', line 2 def type @type end |
Instance Method Details
#solr_filter_for(value) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/supernova/condition.rb', line 9 def solr_filter_for(value) case type when :not, :ne if value.nil? "#{self.key}:[* TO *]" else "!#{self.key}:#{value}" end when :gt "#{self.key}:{#{value} TO *}" when :gte "#{self.key}:[#{value} TO *]" when :lt "#{self.key}:{* TO #{value}}" when :lte "#{self.key}:[* TO #{value}]" end end |