Somewhat similar thing in ruby