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.
31 32 33 34 |
# File 'lib/protocol/rack/body/streaming.rb', line 31 def initialize(block, input = nil) @block = block @input = input end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
36 37 38 |
# File 'lib/protocol/rack/body/streaming.rb', line 36 def block @block end |
Instance Method Details
#call(stream) ⇒ Object
48 49 50 |
# File 'lib/protocol/rack/body/streaming.rb', line 48 def call(stream) @block.call(stream) end |
#each(&block) ⇒ Object
38 39 40 41 42 |
# File 'lib/protocol/rack/body/streaming.rb', line 38 def each(&block) stream = ::Protocol::HTTP::Body::Stream.new(@input, Output.new(block)) @block.call(stream) end |
#stream? ⇒ Boolean
44 45 46 |
# File 'lib/protocol/rack/body/streaming.rb', line 44 def stream? true end |