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.
137 138 139 |
# File 'lib/serverless_rack.rb', line 137 def initialize @buffer = '' end |
Instance Attribute Details
#buffer ⇒ Object (readonly) Also known as: read
Returns the value of attribute buffer.
135 136 137 |
# File 'lib/serverless_rack.rb', line 135 def buffer @buffer end |
Class Method Details
.[](streaming_body) ⇒ Object
141 142 143 144 145 |
# File 'lib/serverless_rack.rb', line 141 def self.[](streaming_body) stream = new streaming_body.call(stream) stream.buffer end |
Instance Method Details
#<<(chunk) ⇒ Object
151 152 153 |
# File 'lib/serverless_rack.rb', line 151 def <<(chunk) write(chunk) end |
#close ⇒ Object
155 |
# File 'lib/serverless_rack.rb', line 155 def close; end |
#flush ⇒ Object
159 160 161 |
# File 'lib/serverless_rack.rb', line 159 def flush @buffer = '' end |
#write(chunk) ⇒ Object
147 148 149 |
# File 'lib/serverless_rack.rb', line 147 def write(chunk) @buffer += chunk end |