Class: Sample

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSample

Returns a new instance of Sample.



225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
# File 'lib/ActionManager.rb', line 225

def initialize
     @am = ActionManager.new(15,true)

     @am.register_action(:SLEEP,method("sleep_action"))
#            @am.register_action(:SLEEP,Proc.new{|s,i| p s ; sleep(s)})
     @am.register_action(:NOP,method("nop_action"))

     def @am.get_runable_action
         action = super
         puts "getting: #{action.inspect}"
         action
     end

     def @am.delete_running_action(action_id)
         puts "deleting: #{action_id}"
         super(action_id)
     end
end

Instance Attribute Details

#amObject (readonly)

Returns the value of attribute am.



223
224
225
# File 'lib/ActionManager.rb', line 223

def am
  @am
end

Class Method Details

.delete_running_action(action_id) ⇒ Object



238
239
240
241
# File 'lib/ActionManager.rb', line 238

def @am.delete_running_action(action_id)
    puts "deleting: #{action_id}"
    super(action_id)
end

.get_runable_actionObject



232
233
234
235
236
# File 'lib/ActionManager.rb', line 232

def @am.get_runable_action
    action = super
    puts "getting: #{action.inspect}"
    action
end

Instance Method Details

#nop_actionObject



250
251
252
# File 'lib/ActionManager.rb', line 250

def nop_action
    p " - Just an action"
end

#sleep_action(secs, id) ⇒ Object



244
245
246
247
248
# File 'lib/ActionManager.rb', line 244

def sleep_action(secs, id)
    p "ID: #{id} sleeping #{secs} seconds"
    sleep(secs)
    p "ID: #{id} Awaken!"
end