state_machine |
class StateMachine < Object |
sm = State_Machine.new( { :ALPHA => { :A => :ALPHA, :B => :BETA }, :BETA => { :A => :ALPHA } }, :ALPHA )sm.change_state(:A) sm.change_state(:B)
Note that you are not limited to using symbols as your states and inputs; you may use any object type you wish (RubyCollections Enums work well).
class InvalidInput < Exception |
Public Methods |
Create a new state machine.
states | a hash: { current_state => { input => new_state } } |
---|---|
initial | state the initial state |
Change state to whichever state is associated with the given input.
Write a picture of the state machine to a file, using GraphR.
orientation | a string, 'portrait' or 'landscape'. |
---|---|
file | the name of the file to write to. |
args | any additional arguments you wish to pass to write_to_file. |
class RecordKeepingStateMachine < StateMachine |
Public Methods |