class TaskJuggler::LogicalExpression

A LogicalExpression is an object that describes tree of LogicalOperation objects and the context that it should be evaluated in.

Attributes

query[R]
sourceFileInfo[R]

Public Class Methods

new(op, sourceFileInfo = nil) click to toggle source

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 30
def initialize(op, sourceFileInfo = nil)
  @operation = op
  @sourceFileInfo = sourceFileInfo

  @query = nil
end

Public Instance Methods

eval(query) click to toggle source

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 40
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
to_s(query = nil) click to toggle source

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 51
def to_s(query = nil)
  if @sourceFileInfo.nil?
    "#{@operation.to_s(query)}"
  else
    "#{@sourceFileInfo} #{@operation.to_s(query)}"
  end
end