Class: Scripted::Group

Inherits:
Object
  • Object
show all
Defined in:
lib/scripted/group.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Group

Returns a new instance of Group.



8
9
10
11
12
# File 'lib/scripted/group.rb', line 8

def initialize(name)
  @name = name
  @parallel = false
  @parallel_id = (object_id ** 2)
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/scripted/group.rb', line 6

def name
  @name
end

Instance Method Details

#commandsObject



30
31
32
# File 'lib/scripted/group.rb', line 30

def commands
  @commands ||= []
end

#define(&block) ⇒ Object



14
15
16
# File 'lib/scripted/group.rb', line 14

def define(&block)
  instance_eval &block if block
end

#parallel(&block) ⇒ Object



23
24
25
26
27
28
# File 'lib/scripted/group.rb', line 23

def parallel(&block)
  @parallel = true
  yield
  @parallel = false
  next_parallel_id
end

#run(name, &block) ⇒ Object



18
19
20
21
# File 'lib/scripted/group.rb', line 18

def run(name, &block)
  next_parallel_id unless in_parallel?
  commands << Command.new(name, :parallel_id => parallel_id, &block)
end