Class: Grntest::Executors::HTTPExecutor::SlowBodyStream
- Inherits:
-
Object
- Object
- Grntest::Executors::HTTPExecutor::SlowBodyStream
- Defined in:
- lib/grntest/executors/http-executor.rb
Instance Method Summary collapse
-
#initialize(body) ⇒ SlowBodyStream
constructor
A new instance of SlowBodyStream.
- #read(length = nil, output = "") ⇒ Object
Constructor Details
#initialize(body) ⇒ SlowBodyStream
Returns a new instance of SlowBodyStream.
25 26 27 28 |
# File 'lib/grntest/executors/http-executor.rb', line 25 def initialize(body) @body = body || "" @offset = 0 end |
Instance Method Details
#read(length = nil, output = "") ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# 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 |