From: Matt Maycock Date: 2004-10-10T05:05:35+09:00 Subject: Re: TempFile Nope :-( Here's my method that I'm using: def handle.add unless block_given? then @done[] @error[ArgumentError, 'Block not given for Plot # data # handle.add. A block is required.'] end file = Tempfile.new('plotdata') filehandle, point = Object.new, @point filehandle.singleton_def(:puts) {|*points| file.puts(point[*points]) } yield filehandle file.close(false) @debug[:data_file, File.readlines(file.path).map {|l| l.chomp}] @add[file] end singleton_def is just this: class Object def singleton_class class << self; self; end end def singleton_def(sym, &block) self.singleton_class.send(:define_method, sym, &block) end end now - I at one point had p FileTest.exists?(file.path) after each line after file was defined. at one point, it was true before the singleton_def, and false afterwards. there are no threads / forking, etc.