Automaton handler for ruby