[#3006] mismatched quotation — "stevan apter" <apter@...>

ruby documentation uses a punctuation convention i've never seen

13 messages 2000/05/27

[ruby-talk:02829] file.size?

From: Aleksi Niemel<aleksi.niemela@...>
Date: 2000-05-16 10:27:23 UTC
List: ruby-talk #2829
=begin
File implements Filetests as class methods but maybe we should
have instance methods for some.

There's two points in my example, I expect file.size
1) to work, that is to work like File.size(file)
2) not to report size of the physical file but
   the size of 'logical' file. I shouldn't be forced to
   flush the buffers to disk before I can query the real size.
=end

def print_unpredictable_many_bytes( file )
    0..rand(1024*10).times { file.print "%c" % rand(256) }
end

filename = "foo"
file = open( filename, "w+" )
print_unpredictable_many_bytes( file )

# fill to nearest kb

# this is what I expect to work
# file.print "\00" * (1023 - (file.size-1) % 1024)

# and this really works (as documented)
file.flush
file.print "\00" * (1023 - ((File.size(file)-1) % 1024))

file.close

In This Thread

Prev Next