Class: Array
- Inherits:
-
Object
show all
- Defined in:
- lib/base/array.rb
Direct Known Subclasses
Add, Analyze, Build, Commit, Doc, Package, Publish, Pull, Push, Setup, Test, Update
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(env = nil) ⇒ Array
Returns a new instance of Array.
4
5
6
7
8
|
# File 'lib/base/array.rb', line 4
def initialize env=nil
@env=env
@env=Environment.new() if @env.nil?
@env=Environmnet.new() if !@env.kind_of?(Environment)
end
|
Instance Attribute Details
#env ⇒ Object
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
36
37
38
|
# File 'lib/base/array.rb', line 36
def add command
self << command if !has_command? command
end
|
#add_passive(command) ⇒ Object
68
69
70
|
# File 'lib/base/array.rb', line 68
def add_passive command
add Command.new({ :input => command, :quiet => true, :ignore_failure => true })
end
|
#add_quiet(command) ⇒ Object
64
65
66
|
# File 'lib/base/array.rb', line 64
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
30
31
32
33
34
|
# 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
if(self[i].is_a?(Command))
self[i].execute
@env.out self[i].summary
end
i=i+1
end
end
|
#has_command?(command) ⇒ Boolean
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/base/array.rb', line 50
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
|
#log_debug_info(title) ⇒ Object
40
41
42
43
44
45
46
47
48
|
# File 'lib/base/array.rb', line 40
def log_debug_info(title)
if defined?(DEBUG) && self.length > 0
puts
puts title
self.each{|c| puts " #{c[:input]}" }
puts
end
end
|
#to_html ⇒ Object
72
73
74
75
76
77
78
79
80
|
# File 'lib/base/array.rb', line 72
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
|