Class: Protocol::HTTP::Body::Writable::Output
- Inherits:
-
Object
- Object
- Protocol::HTTP::Body::Writable::Output
- Defined in:
- lib/protocol/http/body/writable.rb
Overview
The output interface for writing chunks to the body.
Instance Method Summary collapse
-
#close(error = nil) ⇒ Object
Close the output stream.
- #closed? ⇒ Boolean
-
#initialize(writable) ⇒ Output
constructor
Initialize the output with the given writable body.
-
#write(chunk) ⇒ Object
(also: #<<)
Write a chunk to the body.
Constructor Details
#initialize(writable) ⇒ Output
Initialize the output with the given writable body.
111 112 113 114 |
# File 'lib/protocol/http/body/writable.rb', line 111 def initialize(writable) @writable = writable @closed = false end |
Instance Method Details
#close(error = nil) ⇒ Object
Close the output stream.
If an error is given, the error will be used to close the body by invoking #close with the error. Otherwise, only the write side of the body will be closed.
133 134 135 136 137 138 139 140 141 |
# File 'lib/protocol/http/body/writable.rb', line 133 def close(error = nil) @closed = true if error @writable.close(error) else @writable.close_write end end |
#closed? ⇒ Boolean
117 118 119 |
# File 'lib/protocol/http/body/writable.rb', line 117 def closed? @closed || @writable.closed? end |
#write(chunk) ⇒ Object Also known as: <<
Write a chunk to the body.
122 123 124 |
# File 'lib/protocol/http/body/writable.rb', line 122 def write(chunk) @writable.write(chunk) end |