class Grntest::Executors::HTTPExecutor::SlowBodyStream

Public Class Methods

new(body) click to toggle source
# File lib/grntest/executors/http-executor.rb, line 25
def initialize(body)
  @body = body || ""
  @offset = 0
end

Public Instance Methods

read(length=nil, output="") click to toggle source
# File lib/grntest/executors/http-executor.rb, line 30
def read(length=nil, output="")
  if @offset >= @body.bytesize
    nil
  else
    if length.nil?
      output.replace(@body.byteslice(@offset..-1))
      @offset = @body.bytesize
      output
    else
      output.replace(@body.byteslice(@offset, 1))
      @offset += 1
      output
    end
  end
end