Class: IO::LikeHelpers::BlockingIO
- Inherits:
-
DelegatedIO
- Object
- AbstractIO
- DelegatedIO
- IO::LikeHelpers::BlockingIO
- Defined in:
- lib/io/like_helpers/blocking_io.rb
Overview
This class implements a stream that always blocks regardless of the blocking state of the delegate.
Instance Method Summary collapse
-
#read(length, buffer: nil, buffer_offset: 0) ⇒ Integer, String
Reads bytes from the stream.
-
#write(buffer, length: buffer.bytesize) ⇒ Integer
Writes bytes to the stream.
Methods inherited from DelegatedIO
#advise, #autoclose=, #autoclose?, #close, #close_on_exec=, #close_on_exec?, create_finalizer, #fcntl, #fdatasync, #fileno, #fsync, #initialize, #inspect, #ioctl, #nonblock=, #nonblock?, #nread, #path, #pid, #pread, #pwrite, #readable?, #ready?, #seek, #stat, #to_io, #tty?, #wait, #writable?
Methods inherited from AbstractIO
#advise, #close, #close_on_exec=, #close_on_exec?, #closed?, #fcntl, #fdatasync, #fileno, #fsync, #initialize, #ioctl, #nonblock, #nonblock=, #nonblock?, #nread, open, #path, #pid, #pread, #pwrite, #readable?, #ready?, #seek, #stat, #to_io, #tty?, #wait, #writable?
Constructor Details
This class inherits a constructor from IO::LikeHelpers::DelegatedIO
Instance Method Details
#read(length, buffer: nil, buffer_offset: 0) ⇒ Integer, String
Reads bytes from the stream.
Note that a partial read will occur if the stream is in non-blocking mode and reading more bytes would block. If no bytes can be read, however, the read will block until at least 1 byte can be read.
29 30 31 |
# File 'lib/io/like_helpers/blocking_io.rb', line 29 def read(length, buffer: nil, buffer_offset: 0) ensure_blocking { super } end |
#write(buffer, length: buffer.bytesize) ⇒ Integer
Writes bytes to the stream.
Note that a partial write will occur if the stream is in non-blocking mode and writing more bytes would block. If no bytes can be written, however, the write will block until at least 1 byte can be written.
46 47 48 |
# File 'lib/io/like_helpers/blocking_io.rb', line 46 def write(buffer, length: buffer.bytesize) ensure_blocking { super } end |