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.



137
138
139
# File 'lib/serverless_rack.rb', line 137

def initialize
  @buffer = ''
end

Instance Attribute Details

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

#closeObject



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

def close; end

#flushObject



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