Or maybe you're simply looking for Marshal? It lets you dump almost
any Ruby object to a file.

http://www.ruby-doc.org/core/classes/Marshal.html

-- Matma Rex