Timeout.timeout already does this, I'm quite sure:

irb(main):001:0> require 'timeout'
=> true
irb(main):002:0> Timeout::timeout(10) { 2*4 }
=> 8

Ruby 2.0.0p247