Module: StateFu::EventArray
- Includes:
- ArrayWithSymbolAccessor
- Defined in:
- lib/support/arrays.rb
Overview
Array extender. Used by Machine to keep a list of events.
Instance Method Summary collapse
-
#from(origin) ⇒ Object
return all events transitioning from the given state.
-
#next ⇒ Object
if next?, return the event.
-
#next? ⇒ Boolean
is there exactly one possible event to fire, with a single target event?.
-
#to(target) ⇒ Object
return all events transitioning to the given state.
Methods included from ArrayWithSymbolAccessor
#[], #all, #except, #names, #only, #rand
Instance Method Details
#from(origin) ⇒ Object
return all events transitioning from the given state
93 94 95 |
# File 'lib/support/arrays.rb', line 93 def from( origin ) select { |e| e.respond_to?(:from?) && e.from?( origin ) } end |
#next ⇒ Object
if next?, return the event
109 110 111 |
# File 'lib/support/arrays.rb', line 109 def next raise NotImplementedError end |
#next? ⇒ Boolean
is there exactly one possible event to fire, with a single target event?
104 105 106 |
# File 'lib/support/arrays.rb', line 104 def next? raise NotImplementedError end |
#to(target) ⇒ Object
return all events transitioning to the given state
98 99 100 |
# File 'lib/support/arrays.rb', line 98 def to( target ) select { |e| e.respond_to?(:to?) && e.to?( target ) } end |