From: Tim Hunter Date: 2009-02-08T05:18:12+09:00 Subject: Re: File#size Roger Pack wrote: >> So you want to know how much you have written? Then use #tell >> http://www.ruby-doc.org/core/classes/IO.html#M002304 >> >> robert > > It appears that #tell gives you the size of the file you're writing to, > and File#stat.size tells you the filesize of files you're reading from, > is that right? #tell tells you where you're at in the file, not the size of the file. If you're in the middle of reading a file, #tell tells you how far you are from the start of file. If you seek to offset 100 in a 100,000 byte file, #tell returns 100, not 100,000. $ ri IO#tell ---------------------------------------------------------------- IO#tell ios.pos => integer ios.tell => integer ------------------------------------------------------------------------ Returns the current offset (in bytes) of ios. f = File.new("testfile") f.pos #=> 0 f.gets #=> "This is line one\n" f.pos #=> 17 -- RMagick: http://rmagick.rubyforge.org/