Stoplight rewritten in ruby