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.
335 336 337 |
# File 'lib/parsing_nesting/tree.rb', line 335 def initialize(exp) self.operand = exp end |
Instance Attribute Details
#operand ⇒ Object
Returns the value of attribute operand.
338 339 340 |
# File 'lib/parsing_nesting/tree.rb', line 338 def operand @operand end |
Instance Method Details
#can_embed? ⇒ Boolean
354 355 356 |
# File 'lib/parsing_nesting/tree.rb', line 354 def false end |
#negate ⇒ Object
358 359 360 |
# File 'lib/parsing_nesting/tree.rb', line 358 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.
344 345 346 347 348 349 350 351 352 |
# File 'lib/parsing_nesting/tree.rb', line 344 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.kind_of?(NotExpression) operand.operand.to_query(solr_params) else "NOT " + operand.to_query(solr_params) end end |