A simple state machine for ruby