From: Peter Vandenabeele Date: 2011-10-17T07:50:54+09:00 Subject: Re: I fixed this - but why does it work? --0016369fa10a4da83604af7251a6 Content-Type: text/plain; charset=UTF-8 On Mon, Oct 17, 2011 at 12:35 AM, Sub Zero wrote: > probably, because File.size(target) calls the *class method* which is > defined for File class, while target.size calls an *instance method* > which is not defined for File class. > That's what I assumed too ... (based on the printed documentation in "Programming Ruby 1.9" Pick Axe which only lists the ). But it turns out both the instance methods and the class method (both on file name and File object) work. Also, trying a case where the file could not be created (forced with an access permission denied) gives another Exception. So, I cannot reproduce the original problem here ... (on Linux) peterv@ASUS:~$ ls -lrt | tail -3 ---------- 1 peterv peterv 0 2011-10-17 00:39 do_not_edit -rw-r--r-- 1 peterv peterv 12 2011-10-17 00:41 test123 -rw-r--r-- 1 peterv peterv 9 2011-10-17 00:42 test peterv@ASUS:~$ ruby -v ruby 1.9.2p290 (2011-07-09 revision 32553) [i686-linux] peterv@ASUS:~$ irb 001:0> f = File.open("test", 'w') => # 002:0> # open for write resets the size to 0 003:0* ^C 003:0> f.size => 0 004:0> f2 = File.open("test123", 'r') => # 005:0> f2.size => 12 006:0> File.size(f2) => 12 007:0> File.size("test123") => 12 008:0> File.open('do_not_edit', 'w') Errno::EACCES: Permission denied - do_not_edit from (irb):8:in `initialize' from (irb):8:in `open' from (irb):8 from /home/peterv/.rvm/rubies/ruby-1.9.2-p290/bin/irb:16:in `
' HTH, Peter --0016369fa10a4da83604af7251a6--