http://rosettacode.org/wiki/Secure_temporary_file#Ruby