Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/base/array.rb

Direct Known Subclasses

Add, Analyze, Build, Commit, Doc, Publish, Pull, Push, Setup, Test, Update

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#envObject

Returns the value of attribute env.



3
4
5
# File 'lib/base/array.rb', line 3

def env
  @env
end

Instance Method Details

#add(command) ⇒ Object



31
32
33
# File 'lib/base/array.rb', line 31

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

#add_passive(command) ⇒ Object



53
54
55
# File 'lib/base/array.rb', line 53

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

#add_quiet(command) ⇒ Object



49
50
51
# File 'lib/base/array.rb', line 49

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

#execute(value = nil) ⇒ Object



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

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

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

    i=i+1
  end
end

#has_command?(command) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/base/array.rb', line 35

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

#intialize(env = nil) ⇒ Object



4
5
6
7
8
# File 'lib/base/array.rb', line 4

def intialize env=nil
  @env=env
  @env=Environment.new() if @env.nil? 
  @env=Environmnet.new() if !@env.kind_of?(Environment)
end

#to_htmlObject



57
58
59
60
61
62
63
64
65
# File 'lib/base/array.rb', line 57

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