module
IO::Buffered
Overview
TheIO::Buffered mixin enhances anIO 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.
Direct including types
- Compress::Deflate::Reader
- Compress::Gzip::Reader
- Compress::Zlib::Reader
- IO::FileDescriptor
- OpenSSL::SSL::Socket
- Socket
Defined in:
io/buffered.crInstance Method Summary
-
#buffer_size : Int32
Return the buffer size used
-
#buffer_size=(value)
Set the buffer size of both the read and write buffer Cannot be changed after any of the buffers have been allocated
-
#close : Nil
Flushes and closes the underlying
IO. -
#flush : self
Flushes any buffered data and the underlying
IO. -
#flush_on_newline=(flush_on_newline : Bool) : Bool
Turns on/off flushing the underlying
IOwhen a newline is written. -
#flush_on_newline? : Bool
Determines if this
IOflushes automatically when a newline is written. -
#peek : Bytes
Returns the bytes hold in the read buffer.
-
#pos : Int64
Returns the current position (in bytes) in this
IO. -
#read(slice : Bytes) : Int32
Buffered implementation of
IO#read(slice). -
#read_buffering=(read_buffering : Bool) : Bool
Turns on/off
IOread buffering. -
#read_buffering? : Bool
Determines whether this
IObuffers reads. -
#rewind : self
Rewinds the underlying
IO. -
#sync=(sync : Bool) : Bool
Turns on/off
IOwrite buffering. -
#sync? : Bool
Determines if this
IOdoes write buffering. -
#unbuffered_close
Closes the wrapped
IO. -
#unbuffered_flush
Flushes the wrapped
IO. -
#unbuffered_read(slice : Bytes)
Reads at mostslice.size bytes from the wrapped
IOintoslice. -
#unbuffered_rewind
Rewinds the wrapped
IO. -
#unbuffered_write(slice : Bytes)
Writesslice entirely into the wrapped
IO. -
#write(slice : Bytes) : Nil
Buffered implementation of
IO#write(slice).
Instance Method Detail
Set the buffer size of both the read and write buffer Cannot be changed after any of the buffers have been allocated
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 thisIO.
File.write("testfile", "hello")
file = File.new("testfile")
file.pos # => 0
file.gets(2) # => "he"
file.pos # => 2
Turns on/offIOwrite buffering. Whensync is set totrue, no buffering
will be done (that is, writing to thisIO is immediately synced to the
underlyingIO).
Reads at mostslice.size bytes from the wrappedIO intoslice.
Returns the number of bytes read.
TODO Add return type restrictionInt32