module
IO::Buffered
Overview
TheIO::Buffered mixin enhances anIOwith input/output buffering.
The buffering behaviour can be turned on/offwith the#sync= and
#read_buffering= methods.
Additionally, several methods, like#gets, are implemented in a more
efficientway.
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 andwrite 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 iswritten. -
#flush_on_newline? : Bool
Determines if this
IOflushes automaticallywhen a newline iswritten. -
#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
Determineswhether this
IObuffers reads. -
#rewind : self
Rewinds the underlying
IO. -
#sync=(sync : Bool) : Bool
Turns on/off
IOwrite buffering. -
#sync? : Bool
Determines if this
IOdoeswrite buffering. -
#unbuffered_close
Closes thewrapped
IO. -
#unbuffered_flush
Flushes thewrapped
IO. -
#unbuffered_read(slice : Bytes)
Reads at mostslice.size bytes from thewrapped
IOintoslice. -
#unbuffered_rewind
Rewinds thewrapped
IO. -
#unbuffered_write(slice : Bytes)
Writesslice entirely into thewrapped
IO. -
#write(slice : Bytes) : Nil
Buffered implementation of
IO#write(slice).
Instance Method Detail
Set the buffer size of both the read andwrite 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 andwhatever 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 thewrappedIO intoslice.
Returns the number of bytes read.
TODO Add return type restrictionInt32