Method: OpenAI::Internal::Util::ReadIOAdapter#initialize

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

#initialize(src, &blk) {|| ... } ⇒ ReadIOAdapter

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.

Returns a new instance of ReadIOAdapter.

Parameters:

  • src (String, Pathname, StringIO, Enumerable<String>)
  • blk (Proc)

Yield Parameters:

  • (String)


453
454
455
456
457
458
459
460
461
462
463
464
465
466
# File 'lib/openai/internal/util.rb', line 453

def initialize(src, &blk)
  @stream =
    case src
    in String
      StringIO.new(src)
    in Pathname
      @closing = true
      src.open(binmode: true)
    else
      src
    end
  @buf = String.new
  @blk = blk
end