Class: ParsingNesting::Tree::NotExpression
- Defined in:
- lib/parsing_nesting/tree.rb
Instance Attribute Summary collapse
-
#operand ⇒ Object
Returns the value of attribute operand.
Instance Method Summary collapse
- #can_embed? ⇒ Boolean
-
#initialize(exp) ⇒ NotExpression
constructor
A new instance of NotExpression.
- #negate ⇒ Object
-
#to_query(solr_params) ⇒ Object
We have to do the weird thing with : AND NOT (real thing), because Solr 1.4.1 seems not to be able to handle “x OR NOT y” otherwise, at least in some cases, but does fine with “x OR (: AND NOT y)”, which should mean the same thing.
Constructor Details
#initialize(exp) ⇒ NotExpression
Returns a new instance of NotExpression.
326 327 328 |
# File 'lib/parsing_nesting/tree.rb', line 326 def initialize(exp) self.operand = exp end |
Instance Attribute Details
#operand ⇒ Object
Returns the value of attribute operand.
329 330 331 |
# File 'lib/parsing_nesting/tree.rb', line 329 def operand @operand end |
Instance Method Details
#can_embed? ⇒ Boolean
345 346 347 |
# File 'lib/parsing_nesting/tree.rb', line 345 def false end |
#negate ⇒ Object
349 350 351 |
# File 'lib/parsing_nesting/tree.rb', line 349 def negate operand end |
#to_query(solr_params) ⇒ Object
We have to do the weird thing with : AND NOT (real thing), because Solr 1.4.1 seems not to be able to handle “x OR NOT y” otherwise, at least in some cases, but does fine with “x OR (: AND NOT y)”, which should mean the same thing.
335 336 337 338 339 340 341 342 343 |
# File 'lib/parsing_nesting/tree.rb', line 335 def to_query(solr_params) # rescue double-nots to not treat them crazy-like and make the query # more work for Solr than it needs to be with a double-negative. if operand.is_a?(NotExpression) operand.operand.to_query(solr_params) else "NOT " + operand.to_query(solr_params) end end |