The MacroTable is used by the TextScanner to store defined macros and resolve them on request later on. A macro is a text pattern that has a name. The pattern may contain variable parts that are replaced by arguments passed during the macro call.
Add a new macro definition to the table or replace an existing one.
# File lib/taskjuggler/TextParser/MacroTable.rb, line 39 39: def add(macro) 40: @macros[macro.name] = macro 41: end
Remove all definitions from the table.
# File lib/taskjuggler/TextParser/MacroTable.rb, line 44 44: def clear 45: @macros = [] 46: end
Returns true only if a macro named name is defined in the table.
# File lib/taskjuggler/TextParser/MacroTable.rb, line 49 49: def include?(name) 50: @macros.include?(name) 51: end
Returns the definition of the macro specified by name as first entry of args. The other entries of args are parameters that are replacing the ${n} tokens in the macro definition. In case the macro call has less arguments than the macro definition uses, the ${n} tokens remain unchanged. No error is generated.
# File lib/taskjuggler/TextParser/MacroTable.rb, line 58 58: def resolve(args, sourceFileInfo) 59: name = args[0] 60: return nil unless @macros[name] 61: 62: resolved = @macros[name].value.dup 63: i = 0 64: args.each do |arg| 65: resolved.gsub!("${#{i}}", arg) 66: i += 1 67: end 68: [ @macros[name], resolved ] 69: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.