Class: Protocol::Rack::Body::Streaming
- Inherits:
-
HTTP::Body::Readable
- Object
- HTTP::Body::Readable
- Protocol::Rack::Body::Streaming
- 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
-
#block ⇒ Object
readonly
Returns the value of attribute block.
Instance Method Summary collapse
- #call(stream) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(block, input = nil) ⇒ Streaming
constructor
A new instance of Streaming.
- #stream? ⇒ Boolean
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
#block ⇒ Object (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
27 28 29 |
# File 'lib/protocol/rack/body/streaming.rb', line 27 def stream? true end |