Class: ResponseInputStream

Inherits:
Object
  • Object
show all
Defined in:
lib/serverless_rack.rb

Overview

Class to buffer a streaming response body

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeResponseInputStream

Returns a new instance of ResponseInputStream.



139
140
141
# File 'lib/serverless_rack.rb', line 139

def initialize
  @buffer = ''
end

Instance Attribute Details

#bufferObject (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

#closeObject



157
# File 'lib/serverless_rack.rb', line 157

def close; end

#flushObject



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