[holy ruby programmers batman!] ConvertableToFile

Avdi Grimm avdi at avdi.org
Fri Feb 22 11:57:39 EST 2008

Just committed: ConvertableToFile utility.

>From the docs:

This module adds a method, #to_file, which dumps the contents of self into a
temp file and then returns the path of that file.  This is particularly useful
when calling out to shell commands which expect their input in the form of

Example: use UNIX 'diff' to compare two objects:

   >> a = ["foo", "bar", "baz"].join("\n")
   => "foo\nbar\nbaz"
   >> b = ["foo", "buz", "baz"].join("\n")
   => "foo\nbuz\nbaz"
   >> puts `diff #{a.to_file} #{b.to_file}`
   < bar
   > buz
   => nil


More information about the Utilitybelt-tinkering mailing list