| Class | ScopedSearch::QueryLanguage::AST::OperatorNode |
| In: |
lib/scoped_search/query_language/ast.rb
|
| Parent: | Node |
| children | [R] | |
| operator | [R] |
# File lib/scoped_search/query_language/ast.rb, line 67
67: def initialize(operator, children) # :nodoc
68: @operator = operator
69: @children = children
70: end
Returns a child node by index, starting with 0.
# File lib/scoped_search/query_language/ast.rb, line 111
111: def [](child_nr)
112: children[child_nr]
113: end
# File lib/scoped_search/query_language/ast.rb, line 83
83: def eql?(node) # :nodoc
84: node.kind_of?(OperatorNode) && node.operator == operator && node.children.eql?(children)
85: end
Returns true if this is an infix operator
# File lib/scoped_search/query_language/ast.rb, line 101
101: def infix?
102: children.length > 1
103: end
Return the left-hand side (LHS) operand for this operator.
# File lib/scoped_search/query_language/ast.rb, line 88
88: def lhs
89: raise ScopedSearch::Exception, "Operator does not have a LHS" if prefix?
90: raise ScopedSearch::Exception, "Operators with more than 2 children do not have LHS/RHS" if children.length > 2
91: children[0]
92: end
Returns true if this is a prefix operator
# File lib/scoped_search/query_language/ast.rb, line 106
106: def prefix?
107: children.length == 1
108: end
Return the right-hand side (RHS) operand for this operator.
# File lib/scoped_search/query_language/ast.rb, line 95
95: def rhs
96: raise ScopedSearch::Exception, "Operators with more than 2 children do not have LHS/RHS" if children.length > 2
97: children.length == 1 ? children[0] : children[1]
98: end