module IO::Buffered
Overview
The IO::Buffered
mixin enhances an IO
with input/output buffering.
The buffering behaviour can be turned on/off with the #sync=
method.
Additionally, several methods, like #gets
, are implemented in a more
efficient way.
Direct including types
Defined in:
io/buffered.crConstant Summary
-
BUFFER_SIZE =
8192
Instance Method Summary
-
#close : Nil
Flushes and closes the underlying
IO
. -
#flush
Flushes any buffered data and the underlying
IO
. -
#flush_on_newline=(flush_on_newline)
Turns on/off flushing the underlying
IO
when a newline is written. -
#flush_on_newline?
Determines if this
IO
flushes automatically when a newline is written. -
#peek : Bytes?
Returns the bytes hold in the read buffer.
-
#read(slice : Bytes)
Buffered implementation of
IO#read(slice)
. -
#rewind
Rewinds the underlying
IO
. -
#sync=(sync)
Turns on/off
IO
buffering. -
#sync?
Determines if this
IO
does buffering. -
#unbuffered_close
Closes the wrapped
IO
. -
#unbuffered_flush
Flushes the wrapped
IO
. -
#unbuffered_read(slice : Bytes)
Reads at most slice.size bytes from the wrapped
IO
into slice. -
#unbuffered_rewind
Rewinds the wrapped
IO
. -
#unbuffered_write(slice : Bytes)
Writes at most slice.size bytes from slice into the wrapped
IO
. -
#write(slice : Bytes)
Buffered implementation of
IO#write(slice)
.
Instance Method Detail
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.
Turns on/off IO
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.
Writes at most slice.size bytes from slice into the wrapped IO
.
Returns the number of bytes written.