Class: Protocol::Rack::Body::Streaming

Inherits:
HTTP::Body::Readable
  • Object
show all
Defined in:
lib/protocol/rack/body/streaming.rb

Overview

Wraps a streaming response body into a compatible Protocol::HTTP body.

Defined Under Namespace

Classes: Output

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(block, input = nil) ⇒ Streaming

Returns a new instance of Streaming.



14
15
16
17
# File 'lib/protocol/rack/body/streaming.rb', line 14

def initialize(block, input = nil)
	@block = block
	@input = input
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



19
20
21
# File 'lib/protocol/rack/body/streaming.rb', line 19

def block
  @block
end

Instance Method Details

#call(stream) ⇒ Object



31
32
33
# File 'lib/protocol/rack/body/streaming.rb', line 31

def call(stream)
	@block.call(stream)
end

#each(&block) ⇒ Object



21
22
23
24
25
# File 'lib/protocol/rack/body/streaming.rb', line 21

def each(&block)
	stream = ::Protocol::HTTP::Body::Stream.new(@input, Output.new(block))
	
	@block.call(stream)
end

#stream?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/protocol/rack/body/streaming.rb', line 27

def stream?
	true
end