William James
1/3/2007 8:42:00 PM
Aaron Patterson wrote:
> I'm trying to read bytes from a file, and it would be handy if there was
> a method that threw an exception if I couldn't read that many bytes, or
> encountered an EOF.
>
> IO#readbytes seems like the perfect method, but I have an instance of File.
> The documentation says that File inherits from IO, but the File instance
> doesn't seem to have the readbytes method. Am I missing something?
s = open('junk'){|f| f.read(10) }
fail if s.size < 10