Class: IO
- Inherits:
-
Object
- Object
- IO
- Defined in:
- lib/io/stream.rb,
lib/io/stream/shim/buffered.rb,
lib/io/stream/shim/readable.rb
Overview
Released under the MIT License. Copyright, 2023-2025, by Samuel Williams.
Defined Under Namespace
Modules: Stream
Class Method Summary collapse
-
.Stream(io) ⇒ Object
Convert any IO-like object into a buffered stream.
Instance Method Summary collapse
-
#buffered=(value) ⇒ Object
Set the buffered state of the IO.
-
#buffered? ⇒ Boolean
Check if the IO is buffered.
-
#readable? ⇒ Boolean
Check if the IO is readable.
Class Method Details
.Stream(io) ⇒ Object
Convert any IO-like object into a buffered stream.
18 19 20 21 22 23 24 |
# File 'lib/io/stream.rb', line 18 def self.Stream(io) if io.is_a?(Stream::Buffered) io else Stream::Buffered.wrap(io) end end |
Instance Method Details
#buffered=(value) ⇒ Object
Set the buffered state of the IO.
16 17 18 |
# File 'lib/io/stream/shim/buffered.rb', line 16 def buffered=(value) self.sync = !value end |
#buffered? ⇒ Boolean
Check if the IO is buffered.
10 11 12 |
# File 'lib/io/stream/shim/buffered.rb', line 10 def buffered? return !self.sync end |
#readable? ⇒ Boolean
Check if the IO is readable.
10 11 12 13 |
# File 'lib/io/stream/shim/readable.rb', line 10 def readable? # Do not call `eof?` here as it is not concurrency-safe and it can block. !closed? end |