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

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

#nextObject

if next?, return the event

Raises:

  • (NotImplementedError)


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?

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


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