Class: HegemonState
- Inherits:
-
Object
- Object
- HegemonState
- Defined in:
- lib/hegemon.rb
Instance Attribute Summary collapse
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Instance Method Summary collapse
- #do_tasks(i = 0) ⇒ Object
-
#initialize(object, state, &block) ⇒ HegemonState
constructor
A new instance of HegemonState.
-
#setup_task(&block) ⇒ Object
TODO.
- #task(&block) ⇒ Object
- #transition_to(state, &block) ⇒ Object
- #transitions ⇒ Object
Constructor Details
#initialize(object, state, &block) ⇒ HegemonState
Returns a new instance of HegemonState.
287 288 289 290 291 292 293 294 295 296 297 298 299 |
# File 'lib/hegemon.rb', line 287 def initialize(object, state, &block) raise ScriptError, "HegemonState must be initialized with a block"\ unless block.is_a? Proc @object = object @state = state @tasks = [] @transitions = Hash.new instance_eval(&block) end |
Instance Attribute Details
#state ⇒ Object (readonly)
Returns the value of attribute state.
285 286 287 |
# File 'lib/hegemon.rb', line 285 def state @state end |
Instance Method Details
#do_tasks(i = 0) ⇒ Object
309 310 311 |
# File 'lib/hegemon.rb', line 309 def do_tasks(i=0) @tasks.each {|proc| @object.instance_exec(i,&proc) } end |
#setup_task(&block) ⇒ Object
TODO
302 303 |
# File 'lib/hegemon.rb', line 302 def setup_task(&block) #TODO end |
#task(&block) ⇒ Object
301 |
# File 'lib/hegemon.rb', line 301 def task(&block); @tasks << block if block; end |
#transition_to(state, &block) ⇒ Object
305 306 307 |
# File 'lib/hegemon.rb', line 305 def transition_to(state, &block) @transitions[state] = HegemonTransition.new(@object, @state, state, &block) end |
#transitions ⇒ Object
313 |
# File 'lib/hegemon.rb', line 313 def transitions; @transitions; end |