Sha256: c6b5f9fc10e3d458c7fb62f0a60b1201f8f786b2feba191daf781e6e30aa7ef4

Contents?: true

Size: 1.87 KB

Versions: 51

Compression:

Stored size: 1.87 KB

Contents

require_relative('environment.rb')
class Array
    attr_accessor :env
    def intialize env=nil
      @env=env
      @env=Environment.new() if @env.nil? 
      @env=Environmnet.new() if !@env.kind_of?(Environment)
    end

    def execute value=nil
      @env=Environment.new() if @env.nil? 
      i=0
      while i < self.length
        #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

    def add command
      self << command if !has_command? command
    end

    def has_command? command
      return true if(command.kind_of?(String) && !include?(command))
      if(command.kind_of?(Command))
        self.each{|c|
          if c.kind_of?(String)
            return true if command[:input] == c
          else
            return true if(c[:input] == command[:input])
          end
        }
      end
      false
    end

    def add_quiet command
      add Command.new({ :input => command, :quiet => true })
    end

    def add_passive command
      add Command.new({ :input => command, :quiet => true, :ignore_failure => true })
    end

    def to_html
      html=Array.new
      html << '<div>'
      self.each{|e|
        html << e.to_html if e.respond_to?(:to_html)
      }
      html << '</div>'
      html.join
    end
end

Version data entries

51 entries across 51 versions & 1 rubygems

Version Path
dev-2.1.22 lib/base/array.rb
dev-2.1.21 lib/base/array.rb
dev-2.1.20 lib/base/array.rb
dev-2.1.19 lib/base/array.rb
dev-2.1.18 lib/base/array.rb
dev-2.1.17 lib/base/array.rb
dev-2.1.16 lib/base/array.rb
dev-2.1.15 lib/base/array.rb
dev-2.1.14 lib/base/array.rb
dev-2.1.13 lib/base/array.rb
dev-2.1.12 lib/base/array.rb
dev-2.1.11 lib/base/array.rb
dev-2.1.10 lib/base/array.rb
dev-2.1.9 lib/base/array.rb
dev-2.1.8 lib/base/array.rb
dev-2.1.7 lib/base/array.rb
dev-2.1.6 lib/base/array.rb
dev-2.1.5 lib/base/array.rb
dev-2.1.4 lib/base/array.rb
dev-2.1.3 lib/base/array.rb