Class: ResponseInputStream
- Inherits:
-
Object
- Object
- ResponseInputStream
- Defined in:
- lib/serverless_rack.rb
Overview
Class to buffer a streaming response body
Instance Attribute Summary collapse
-
#buffer ⇒ Object
(also: #read)
readonly
Returns the value of attribute buffer.
Class Method Summary collapse
Instance Method Summary collapse
- #<<(chunk) ⇒ Object
- #close ⇒ Object
- #flush ⇒ Object
-
#initialize ⇒ ResponseInputStream
constructor
A new instance of ResponseInputStream.
- #write(chunk) ⇒ Object
Constructor Details
#initialize ⇒ ResponseInputStream
Returns a new instance of ResponseInputStream.
139 140 141 |
# File 'lib/serverless_rack.rb', line 139 def initialize @buffer = '' end |
Instance Attribute Details
#buffer ⇒ Object (readonly) Also known as: read
Returns the value of attribute buffer.
137 138 139 |
# File 'lib/serverless_rack.rb', line 137 def buffer @buffer end |
Class Method Details
.[](streaming_body) ⇒ Object
143 144 145 146 147 |
# File 'lib/serverless_rack.rb', line 143 def self.[](streaming_body) stream = new streaming_body.call(stream) stream.buffer end |
Instance Method Details
#<<(chunk) ⇒ Object
153 154 155 |
# File 'lib/serverless_rack.rb', line 153 def <<(chunk) write(chunk) end |
#close ⇒ Object
157 |
# File 'lib/serverless_rack.rb', line 157 def close; end |
#flush ⇒ Object
161 162 163 |
# File 'lib/serverless_rack.rb', line 161 def flush @buffer = '' end |
#write(chunk) ⇒ Object
149 150 151 |
# File 'lib/serverless_rack.rb', line 149 def write(chunk) @buffer += chunk end |