Class: IO::Stream::Generic
- Inherits:
-
Object
- Object
- IO::Stream::Generic
- Defined in:
- lib/io/stream/generic.rb
Overview
Base class for stream implementations providing common functionality.
Direct Known Subclasses
Constant Summary
Constants included from Writable
Constants included from Readable
Instance Attribute Summary
Attributes included from Writable
Attributes included from Readable
Class Method Summary collapse
-
.async_safe?(method) ⇒ Boolean
Check if a method is async-safe.
Instance Method Summary collapse
-
#close ⇒ Object
Best effort to flush any unwritten data, and then close the underling IO.
-
#closed? ⇒ Boolean
Check if the stream is closed.
-
#initialize(**options) ⇒ Generic
constructor
Initialize a new generic stream.
Methods included from Writable
#<<, #close_write, #flush, #puts, #write
Methods included from Readable
#block_size, #block_size=, #close_read, #discard_until, #finish!, #finished?, #gets, #peek, #read, #read_exactly, #read_partial, #read_until, #readable?, #readpartial
Constructor Details
#initialize(**options) ⇒ Generic
Initialize a new generic stream.
31 32 33 |
# File 'lib/io/stream/generic.rb', line 31 def initialize(**) super(**) end |
Class Method Details
.async_safe?(method) ⇒ Boolean
Check if a method is async-safe.
25 26 27 |
# File 'lib/io/stream/generic.rb', line 25 def self.async_safe?(method) Readable.async_safe?(method) || Writable.async_safe?(method) end |
Instance Method Details
#close ⇒ Object
Best effort to flush any unwritten data, and then close the underling IO.
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/io/stream/generic.rb', line 42 def close return if closed? begin self.flush rescue # We really can't do anything here unless we want #close to raise exceptions. ensure self.sysclose end end |
#closed? ⇒ Boolean
Check if the stream is closed.
37 38 39 |
# File 'lib/io/stream/generic.rb', line 37 def closed? false end |