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.
108 109 110 111 |
# File 'lib/protocol/http/body/writable.rb', line 108 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.
130 131 132 133 134 135 136 137 138 |
# File 'lib/protocol/http/body/writable.rb', line 130 def close(error = nil) @closed = true if error @writable.close(error) else @writable.close_write end end |
#closed? ⇒ Boolean
114 115 116 |
# File 'lib/protocol/http/body/writable.rb', line 114 def closed? @closed || @writable.closed? end |
#write(chunk) ⇒ Object Also known as: <<
Write a chunk to the body.
119 120 121 |
# File 'lib/protocol/http/body/writable.rb', line 119 def write(chunk) @writable.write(chunk) end |