Protocol::HTTPSourceProtocolHTTPBodyStreamableOutput

class Output

A output stream that can be written to by a block.

Definitions

def self.schedule(input, block)

Schedule the block to be executed in a fiber.

Signature

parameter input Readable

The input stream.

parameter block Proc

The block that generates the output.

returns Output

The output stream.

Implementation

def self.schedule(input, block)
	self.new(input, block).tap(&:schedule)
end

def schedule

Schedule the block to be executed in a fiber.

Signature

returns Fiber

The fiber.

Implementation

def schedule
	@fiber ||= Fiber.schedule do
		@block.call(@stream)
	end
end

def initialize(input, block)

Initialize the output stream with the given input and block.

Signature

parameter input Readable

The input stream.

parameter block Proc

The block that generates the output.

Implementation

def initialize(input, block)
	@output = Writable.new
	@stream = Stream.new(input, @output)
	@block = block
end

def read

Read from the output stream (may block).

Implementation

def read
	@output.read
end

def close(error = nil)

Close the output stream.

Signature

parameter error Exception | Nil

The error that caused this stream to be closed, if any.

Implementation

def close(error = nil)
	@output.close_write(error)
end