class Protocol::HTTP::Body::Streamable::Output
A output stream that can be written to by a block.
def self.schedule(input, block)
@parameter block [Proc] The block that generates the output.
@parameter input [Readable] The input stream.
Schedule the block to be executed in a fiber.
def self.schedule(input, block) self.new(input, block).tap(&:schedule) end
def close(error = nil)
Close the output stream.
def close(error = nil) @output.close_write(error) end
def initialize(input, block)
@parameter input [Readable] The input stream.
Initialize the output stream with the given input and block.
def initialize(input, block) @output = Writable.new @stream = Stream.new(input, @output) @block = block end
def read
def read @output.read end
def schedule
Schedule the block to be executed in a fiber.
def schedule @fiber ||= Fiber.schedule do @block.call(@stream) end end