Module: ScopedSearch::QueryLanguage::AST
- Defined in:
- lib/scoped_search/query_language/ast.rb
Defined Under Namespace
Classes: LeafNode, LogicalOperatorNode, Node, OperatorNode
Class Method Summary collapse
-
.from_array(arg) ⇒ Object
Constructs an AST from an array notation.
Class Method Details
.from_array(arg) ⇒ Object
Constructs an AST from an array notation.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/scoped_search/query_language/ast.rb', line 4 def self.from_array(arg) if arg.kind_of?(Array) operator = arg.shift case operator when :and, :or LogicalOperatorNode.new(operator, arg.map { |c| from_array(c) }) when Symbol OperatorNode.new(operator, arg.map { |c| from_array(c) }) else raise ScopedSearch::Exception, "Not a valid array representation of an AST!" end else return LeafNode.new(arg) end end |