add ruby solution to q040