This class staples together two unidirectional IOs to form a single,
bidirectional IO.
Example (loopback):
io = IO::Stapled.new(*IO.pipe)
io.puts "linus"
io.gets # => "linus"
Most methods simply delegate to the underlying IOs.
Constructors
new(reader :
IO, writer :
IO, sync_close :
Bool = false)
Creates a new IO::Stapled which reads from reader and writes to writer.
SourceClass methods
pipe(read_blocking :
Bool |
Nil = nil, write_blocking :
Bool |
Nil = nil, &)
Creates a pair of bidirectional pipe endpoints connected with each other
and passes them to the given block.
Both endpoints and the underlying IOs are closed after the block
(even if sync_close? is false).
Sourcepipe(read_blocking :
Bool |
Nil = nil, write_blocking :
Bool |
Nil = nil) :
Tuple(self, self)
Creates a pair of bidirectional pipe endpoints connected with each other
and returns them in a Tuple.
SourceInstance methods
close
Closes this IO.
If sync_close? is true, it will also close the underlying IOs.
Sourceclosed?
Returns true if this IO is closed.
Underlying IOs might have a different status.
Sourcegets(delimiter :
Char, limit :
Int, chomp = false) :
String |
Nil Gets a string from reader.
SourceReads a slice from reader.
Sourceread_byte
Reads a single byte from reader.
Sourcesync_close=(sync_close :
Bool)
If #sync_close? is true, closing this IO will close the underlying IOs.
Sourcesync_close?
If #sync_close? is true, closing this IO will close the underlying IOs.
Sourcewrite(slice :
Bytes) :
Nil Writes a slice to writer.
Source