class IO::Stapled
inherits IO
¶
This class staples together two unidirectional IO
s 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 IO
s.
Class methods¶
.pipe(read_blocking : Bool = false, write_blocking : Bool = false
¶
(read_blocking : Bool = false, write_blocking : Bool = false
Creates a pair of bidirectional pipe endpoints connected with each other and passes them to the given block.
Both endpoints and the underlying IO
s are closed after the block
(even if sync_close?
is false
).
.pipe(read_blocking : Bool = false, write_blocking : Bool = false) : Tuple(self, self)
¶
(read_blocking : Bool = false, write_blocking : Bool = false) : Tuple(self, self)
Creates a pair of bidirectional pipe endpoints connected with each other
and returns them in a Tuple
.
.new(reader : IO, writer : IO, sync_close : Bool = false)
¶
(reader : IO, writer : IO, sync_close : Bool = false)
Creates a new IO::Stapled
which reads from reader and writes to writer.
Methods¶
#close : Nil
¶
: Nil
Closes this IO
.
If sync_close?
is true
, it will also close the underlying IO
s.
#closed? : Bool
¶
View source
: Bool
#gets(delimiter : Char, limit : Int, chomp = false) : String?
¶
(delimiter : Char, limit : Int, chomp = false) : String?
Gets a string from reader
.
#sync_close=(sync_close : Bool)
¶
(sync_close : Bool)
If #sync_close?
is true
, closing this IO
will close the underlying IO
s.
#sync_close? : Bool
¶
: Bool
If #sync_close?
is true
, closing this IO
will close the underlying IO
s.