On Sun, 10 Oct 2004, Matt Maycock wrote: > 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. > > > i'm not sure how, but your tempfile is being garbage collected from somewhere and it's causing the file to be removed. of course, you probably knew that - i can't imagine why, though... -a -- =============================================================================== | EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov | PHONE :: 303.497.6469 | A flower falls, even though we love it; | and a weed grows, even though we do not love it. | --Dogen ===============================================================================