Class: Protocol::HTTP::Executor::Body::StreamOutput
- Inherits:
-
Object
- Object
- Protocol::HTTP::Executor::Body::StreamOutput
- Defined in:
- lib/protocol/http/executor/body/output.rb
Overview
A writable output used while executing a streamable body in the worker.
Instance Method Summary collapse
-
#close(error = nil) ⇒ Object
Close the stream output for writing.
-
#close_write(error = nil) ⇒ Object
Close the stream output for writing.
- #closed? ⇒ Boolean
- #empty? ⇒ Boolean
-
#flush ⇒ Object
Flush pending output.
-
#initialize(channel) ⇒ StreamOutput
constructor
Initialize a stream output.
-
#write(chunk) ⇒ Object
(also: #<<)
Write an output chunk.
Constructor Details
#initialize(channel) ⇒ StreamOutput
Initialize a stream output.
135 136 137 138 |
# File 'lib/protocol/http/executor/body/output.rb', line 135 def initialize(channel) @channel = channel @closed = false end |
Instance Method Details
#close(error = nil) ⇒ Object
Close the stream output for writing.
160 161 162 |
# File 'lib/protocol/http/executor/body/output.rb', line 160 def close(error = nil) close_write(error) end |
#close_write(error = nil) ⇒ Object
Close the stream output for writing.
155 156 157 |
# File 'lib/protocol/http/executor/body/output.rb', line 155 def close_write(error = nil) @closed = true end |
#closed? ⇒ Boolean
165 166 167 |
# File 'lib/protocol/http/executor/body/output.rb', line 165 def closed? @closed end |
#empty? ⇒ Boolean
170 171 172 |
# File 'lib/protocol/http/executor/body/output.rb', line 170 def empty? true end |
#flush ⇒ Object
Flush pending output.
151 152 |
# File 'lib/protocol/http/executor/body/output.rb', line 151 def flush end |
#write(chunk) ⇒ Object Also known as: <<
Write an output chunk.
141 142 143 144 145 146 |
# File 'lib/protocol/http/executor/body/output.rb', line 141 def write(chunk) raise IOError, "The stream output is closed!" if @closed @channel.write(:chunk, chunk) return chunk.bytesize end |