Reimplement mock control script in Ruby