class TracLang::Expression

Model of TRAC neutral string expression. An expression is an array of strings, corresponding to the arguments of a TRAC expression. Expressions are active if they were called by #(…) and not active (neutral) if they were called by ##(…).

Attributes

active[RW]

Flag to tell if this expression is active or neutral. The result of active expressions are copied to the active string, while the result of neutral expressions are copied to the enclosing expression.

active?[RW]

Flag to tell if this expression is active or neutral. The result of active expressions are copied to the active string, while the result of neutral expressions are copied to the enclosing expression.

args[RW]

List of arguments for this expression.

Public Class Methods

new() click to toggle source

Creates new active expression.

# File lib/trac_lang/expression.rb, line 21
def initialize
  @args = ['']
  @active = true
end

Public Instance Methods

command() click to toggle source

Command for TRAC processor.

# File lib/trac_lang/expression.rb, line 27
def command
  @args[0].downcase.to_sym
end
concat(str) click to toggle source

Adds a string to current argument of the expression.

# File lib/trac_lang/expression.rb, line 37
def concat(str)
  @args.last.concat str
end
newarg() click to toggle source

Signals a new argument is starting.

# File lib/trac_lang/expression.rb, line 42
def newarg
  @args.push ''
end
size() click to toggle source

Returns current number of arguments in expression.

# File lib/trac_lang/expression.rb, line 47
def size
  @args.size
end
to_s() click to toggle source

String version of expression, used when trace is on

# File lib/trac_lang/expression.rb, line 52
def to_s
  (@active ? '#/' : '##/') + @args.join('*') + '/'
end
trac_args() click to toggle source

Arguments for TRAC command.

# File lib/trac_lang/expression.rb, line 32
def trac_args
  @args[1..-1]
end