class Output
The output interface for writing chunks to the body.
Definitions
def initialize(writable)
Initialize the output with the given writable body.
Signature
-
parameter
writable
Writable
The writable body.
Implementation
def initialize(writable)
@writable = writable
@closed = false
end
def closed?
Signature
-
returns
Boolean
Whether the output is closed for writing only.
Implementation
def closed?
@closed || @writable.closed?
end
def write(chunk)
Write a chunk to the body.
Implementation
def write(chunk)
@writable.write(chunk)
end
def close(error = nil)
Close the output stream.
If an error is given, the error will be used to close the body by invoking Protocol::HTTP::Body::Writable::Output#close
with the error. Otherwise, only the write side of the body will be closed.
Signature
-
parameter
error
Exception | Nil
The error that caused this stream to be closed, if any.
Implementation
def close(error = nil)
@closed = true
if error
@writable.close(error)
else
@writable.close_write
end
end