Method: Array#execute

Defined in:
lib/base/array.rb

#execute(value = nil) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/base/array.rb', line 10

def execute value=nil
  @env=Environment.new() if @env.nil? 
  i=0
  #puts "Array.execute length=#{self.length}" if defined?(DEBUG)
  while i < self.length

    #puts self[i].to_s if defined?(DEBUG)
    #puts "Array[#{i.to_s}]'=nil" if @env.debug? && self[i].nil?
    #puts "Array[#{i.to_s}].class=#{self[i].class.to_s}" if @env.debug? && !self[i].nil?
    #puts "Array[#{i.to_s}].to_s=#{self[i].to_s}" if @env.debug? && !self[i].nil?
    self[i]=Command.new({ :input => self[i], :quiet => true }) if(self[i].is_a?(String))
    self[i]=Command.new(self[i]) if(self[i].is_a?(Hash) && !self[i].is_a?(Command))

    if(!value.nil? && value.is_a?(Hash))
      value.each{|k,v|self[i][k]=v}
    end

    if(self[i].is_a?(Command))
      self[i].execute
      @env.out self[i].summary
    end

    i=i+1
  end
end