Class: TracLang::Expression
- Inherits:
-
Object
- Object
- TracLang::Expression
- Defined in:
- lib/trac_lang/expression.rb
Overview
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 ##(…).
Instance Attribute Summary collapse
-
#active ⇒ Object
(also: #active?)
Flag to tell if this expression is active or neutral.
-
#args ⇒ Object
List of arguments for this expression.
Instance Method Summary collapse
-
#command ⇒ Object
Command for TRAC processor.
-
#concat(str) ⇒ Object
Adds a string to current argument of the expression.
-
#initialize ⇒ Expression
constructor
Creates new active expression.
-
#newarg ⇒ Object
Signals a new argument is starting.
-
#size ⇒ Object
Returns current number of arguments in expression.
-
#to_s ⇒ Object
String version of expression, used when trace is on.
-
#trac_args ⇒ Object
Arguments for TRAC command.
Constructor Details
#initialize ⇒ Expression
Creates new active expression.
21 22 23 24 |
# File 'lib/trac_lang/expression.rb', line 21 def initialize @args = [''] @active = true end |
Instance Attribute Details
#active ⇒ Object Also known as: active?
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.
13 14 15 |
# File 'lib/trac_lang/expression.rb', line 13 def active @active end |
#args ⇒ Object
List of arguments for this expression.
16 17 18 |
# File 'lib/trac_lang/expression.rb', line 16 def args @args end |
Instance Method Details
#command ⇒ Object
Command for TRAC processor.
27 28 29 |
# File 'lib/trac_lang/expression.rb', line 27 def command @args[0].downcase.to_sym end |
#concat(str) ⇒ Object
Adds a string to current argument of the expression.
37 38 39 |
# File 'lib/trac_lang/expression.rb', line 37 def concat(str) @args.last.concat str end |
#newarg ⇒ Object
Signals a new argument is starting.
42 43 44 |
# File 'lib/trac_lang/expression.rb', line 42 def newarg @args.push '' end |
#size ⇒ Object
Returns current number of arguments in expression.
47 48 49 |
# File 'lib/trac_lang/expression.rb', line 47 def size @args.size end |
#to_s ⇒ Object
String version of expression, used when trace is on
52 53 54 |
# File 'lib/trac_lang/expression.rb', line 52 def to_s (@active ? '#/' : '##/') + @args.join('*') + '/' end |
#trac_args ⇒ Object
Arguments for TRAC command.
32 33 34 |
# File 'lib/trac_lang/expression.rb', line 32 def trac_args @args[1..-1] end |