This is one of the magic things in Ruby, blocks.  You wanted to do something given a temporary file with some content... so why not define that "something" as a block (the `unrtf`...), and then pass that to another function that deals with the details of opening the temporary file, writing to it, closing it, and eventually deleting it.