Module: Panda
- Defined in:
- lib/panda/build.rb,
lib/panda/expressions.rb,
lib/panda/expressers/inspector.rb,
lib/panda/expressers/tree_expresser.rb,
lib/panda/expressers/examples/sql_expresser.rb
Defined Under Namespace
Modules: Expressers Classes: Boolean, Comparison, Expression, Node, Subject, SubjectGenerator, SyntaxError
Class Method Summary collapse
-
.build ⇒ Object
Returns the result of the given block, which is passed a new SubjectGenerator object.
Class Method Details
.build ⇒ Object
Returns the result of the given block, which is passed a new SubjectGenerator object. If the given block does not return a Panda expression AST then a Panda::SyntaxError exception is raised.
ast = Panda.build { |s| (s.name == 'FooHoney') | (s.booty.like 'whoa!') }
puts ast
puts ast.inspect
produces:
#<Panda::Boolean:0x8255ca8>
(name == "FooHoney" | booty like "whoa!")
44 45 46 47 48 49 |
# File 'lib/panda/build.rb', line 44 def self.build unless Panda::Node === ast = yield(SubjectGenerator.new) raise SyntaxError, "Invalid PANDA expression: \"#{ast}\". Are you using the != operator, perhaps?" end return ast end |