Class: EventMachine::Scenario::AdLib
- Inherits:
-
Object
- Object
- EventMachine::Scenario::AdLib
- Includes:
- EM::Deferrable
- Defined in:
- lib/scenario/latin.rb
Overview
Repeat sequentially an action
Instance Method Summary collapse
- #finally(&block) ⇒ Object
-
#initialize(times, &block) ⇒ AdLib
constructor
A new instance of AdLib.
- #nextStep ⇒ Object
Constructor Details
#initialize(times, &block) ⇒ AdLib
Returns a new instance of AdLib.
123 124 125 126 127 128 |
# File 'lib/scenario/latin.rb', line 123 def initialize times, &block @cpt = 0 @times = times @loop = block self end |
Instance Method Details
#finally(&block) ⇒ Object
130 131 132 133 |
# File 'lib/scenario/latin.rb', line 130 def finally &block self.callback(&block) self.nextStep end |
#nextStep ⇒ Object
135 136 137 138 139 140 141 142 |
# File 'lib/scenario/latin.rb', line 135 def nextStep if @cpt == @times self.succeed else @loop.call( Proc.new {nextStep}, @cpt) @cpt += 1 end end |