In article <200411031959.18376.jim / weirichhouse.org>,
Jim Weirich  <jim / weirichhouse.org> wrote:
>On Wednesday 03 November 2004 11:34 am, Eivind Eklund wrote:
>> Wouldn't this be better implemented as meta-programming in Ruby, 
>
>Funny you should mention this ... I was playing with ruby state machines about 
>two weeks ago (even using the turnstile example in my unit tests).  This is 
>what I came up with ....
>
>  class TurnStileFSM < StateMachine
>    state_machine do
>      state :locked do
>        start_state
>        event :coin, :unlocked,  :unlock
>        event :pass, :violation, :alarm_on
>      end
>      state :unlocked do
>        event :coin, :unlocked, :thank_you
>        event :pass, :locked,   :lock
>      end
>      state :violation do
>        event :reset, :violation
>        event :ready, :locked, :alarm_off, :lock
>        event :pass
>        event :coin
>      end
>    end
>  end
>
>To use, you just inherit from the FSM and implement the actions (e.g. unlock, 
>lock, alarm_on).   (Or I suppose you could implement the actions directly in 
>the FSM class).
>

Where would one find the StateMachine class/module that you're inheriting 
from in the code above?


Phil