Class: Sample
- Inherits:
-
Object
- Object
- Sample
- Defined in:
- lib/ActionManager.rb
Instance Attribute Summary collapse
-
#am ⇒ Object
readonly
Returns the value of attribute am.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Sample
constructor
A new instance of Sample.
- #nop_action ⇒ Object
- #sleep_action(secs, id) ⇒ Object
Constructor Details
#initialize ⇒ Sample
Returns a new instance of Sample.
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
# File 'lib/ActionManager.rb', line 227 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
#am ⇒ Object (readonly)
Returns the value of attribute am.
225 226 227 |
# File 'lib/ActionManager.rb', line 225 def am @am end |
Class Method Details
.delete_running_action(action_id) ⇒ Object
240 241 242 243 |
# File 'lib/ActionManager.rb', line 240 def @am.delete_running_action(action_id) puts "deleting: #{action_id}" super(action_id) end |
.get_runable_action ⇒ Object
234 235 236 237 238 |
# File 'lib/ActionManager.rb', line 234 def @am.get_runable_action action = super puts "getting: #{action.inspect}" action end |
Instance Method Details
#nop_action ⇒ Object
252 253 254 |
# File 'lib/ActionManager.rb', line 252 def nop_action p " - Just an action" end |
#sleep_action(secs, id) ⇒ Object
246 247 248 249 250 |
# File 'lib/ActionManager.rb', line 246 def sleep_action(secs, id) p "ID: #{id} sleeping #{secs} seconds" sleep(secs) p "ID: #{id} Awaken!" end |