Very simple Ruby state machine.