IO::Buffered
The IO::Buffered mixin enhances an IO with input/output buffering.
The buffering behaviour can be turned on/off with the #sync= and
#read_buffering= methods.
Additionally, several methods, like #gets, are implemented in a more
efficient way.
Instance methods
Set the buffer size of both the read and write buffer Cannot be changed after any of the buffers have been allocated
Turns on/off flushing the underlying IO when a newline is written.
Returns the bytes hold in the read buffer.
This method only performs a read to return peek data if the current buffer is empty: otherwise no read is performed and whatever is in the buffer is returned.
Returns the current position (in bytes) in this IO.
File.write("testfile", "hello")
file = File.new("testfile")
file.pos # => 0
file.gets(2) # => "he"
file.pos # => 2
Turns on/off IO write buffering. When sync is set to true, no buffering
will be done (that is, writing to this IO is immediately synced to the
underlying IO).
Reads at most slice.size bytes from the wrapped IO into slice.
Returns the number of bytes read.
TODO: Add return type restriction Int32