 
 This page contains automated test results for code from O'Reilly's Ruby Cookbook. If this code looks interesting or useful, you might want to buy the whole book.
| Writing to a Temporary File | ||
|---|---|---|
| Code | Expected | Actual | 
| require 'tempfile'
out = Tempfile.new("tempfile")
out.path | "/tmp/tempfile23786.0" | "/tmp/tempfile18070.0" | 
| out << "Some text." out.rewind out.read | "Some text." | "Some text." | 
| out.close
out = Tempfile.new("myhome_tempfile", "/home/leonardr/temp/")
require 'fileutils'
FileUtils.mv(out.path, "/home/leonardr/old_tempfile") | nil | |