Brogue code converted to Ruby and RubyMotion