class ZabconExecuteContainer
Attributes
options[R]
results[R]
show_params[R]
Public Class Methods
new(tokens)
click to toggle source
# File libs/command_tree.rb, line 119 def initialize(tokens) @initial_tokens=tokens @commands=[] @printing=true commandlist=CommandList.instance pos=tokens.walk(0) if (positions=tokens.assignment?(pos,:return_pos=>true)) var_name = tokens[positions[0]].value debug(5,:var=>var_name,:msg=>"Creating Variable assignment") add(ZabconExecuteVariable.new(var_name)) tokens=tokens.drop(positions[2]+1) end cmd_str=tokens.map{|i| # if i.kind==:variable # name=/^\$(.*)/.match(i.value)[1] # GlobalVars.instance[name] || env[name] # else i.value # end }.join debug(5,:msg=>"Command String",:var=>cmd_str) cmd=commandlist.find_and_parse(cmd_str) add(ZabconExecuteCommand.new(cmd)) end
Public Instance Methods
add(obj)
click to toggle source
# File libs/command_tree.rb, line 151 def add(obj) raise "Expected ZabconExecuteCommand Class" if obj.class!=ZabconExecuteCommand && obj.class!=ZabconExecuteVariable @commands<<obj if obj.class==ZabconExecuteCommand @printing=@printing & obj.print? @show_params=obj.show_params @options=obj.options end end
execute()
click to toggle source
# File libs/command_tree.rb, line 164 def execute stack=[] ptr=0 while ptr<@commands.length case @commands[ptr].class.to_s when "ZabconExecuteCommand" @commands[ptr].execute @results=@commands[ptr].results when "ZabconExecuteVariable" stack<<ptr end ptr+=1 end while !stack.empty? ptr=stack.pop @commands[ptr].assign(@results) end end
print?()
click to toggle source
# File libs/command_tree.rb, line 147 def print? @printing==true #Ensure we get a boolean ;-) end