Method: OpenAI::Internal::Util::ReadIOAdapter#read

Defined in:
lib/openai/internal/util.rb

#read(max_len = nil, out_string = nil) ⇒ String?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • max_len (Integer, nil) (defaults to: nil)
  • out_string (String, nil) (defaults to: nil)

Returns:

  • (String, nil)


429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
# File 'lib/openai/internal/util.rb', line 429

def read(max_len = nil, out_string = nil)
  case @stream
  in nil
    nil
  in IO | StringIO
    @stream.read(max_len, out_string)
  in Enumerator
    read = read_enum(max_len)
    case out_string
    in String
      out_string.replace(read)
    in nil
      read
    end
  end
    .tap(&@blk)
end