Class TaskJuggler::LogicalExpression
In: lib/taskjuggler/LogicalExpression.rb
Parent: Object

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

Methods

eval   new   to_s  

Attributes

query  [R] 
sourceFileInfo  [R] 

Public Class methods

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.

[Source]

# File lib/taskjuggler/LogicalExpression.rb, line 30
    def initialize(op, sourceFileInfo = nil)
      @operation = op
      @sourceFileInfo = sourceFileInfo

      @query = nil
    end

Public Instance methods

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.

[Source]

# 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

Dump the LogicalExpression as a String. If query is provided, it will show the actual values, otherwise just the variable names.

[Source]

# 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

[Validate]