How about this:

--
require 'io/wait'

loop do
  # my processing stuff
  if STDIN.ready?
    # handle input
  end
end

-- 
Lennon
rcoder.net