A LogicalExpression is an object that describes tree of LogicalOperation objects and the context that it should be evaluated in.
Create a new LogicalExpression object. op must be a LogicalOperation. sourceFileInfo is the file position where expression started. It may be nil if not available.
# File lib/taskjuggler/LogicalExpression.rb, line 28 def initialize(op, sourceFileInfo = nil) @operation = op @sourceFileInfo = sourceFileInfo @query = nil end
This function triggers the evaluation of the expression. property is the PropertyTreeNode that should be used for the evaluation. scopeProperty is the PropertyTreeNode that describes the scope. It may be nil.
# File lib/taskjuggler/LogicalExpression.rb, line 38 def eval(query) @query = query res = @operation.eval(self) return res if res.is_a?(TrueClass) || res.is_a?(FalseClass) || res.is_a?(String) # In TJP syntax 'non 0' means false. return res != 0 end
Dump the LogicalExpression as a String. If query is provided, it will show the actual values, otherwise just the variable names.
# File lib/taskjuggler/LogicalExpression.rb, line 49 def to_s(query = nil) if @sourceFileInfo.nil? "#{@operation.to_s(query)}" else "#{@sourceFileInfo} #{@operation.to_s(query)}" end end