I needed this over the weekend and the existing online help is less than helpful. As it turns out, just like with everything I try to do in Ruby, the solution is simple.

require 'tmpdir'
temp = Dir.tmpdir() 
puts temp #C:/Users/Robert/AppData/Local/Temp

This is all built into Ruby, you don't need to install any gems or anything.