class Anthropic::Internal::Util::ReadIOAdapter
An adapter that satisfies the IO interface required by ‘::IO.copy_stream`
@api private
def close
- Api: - private
def close case @stream in Enumerator Anthropic::Internal::Util.close_fused!(@stream) in IO if close? @stream.close else end end
def close? = @closing
-
(Boolean, nil)
-
Other tags:
- Api: - private
def close? = @closing
def initialize(src, &blk)
- Yieldparam: -
Parameters:
-
blk
(Proc
) -- -
src
(String, Pathname, StringIO, Enumerable
) --
Other tags:
- Api: - private
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.b @blk = blk end
def read(max_len = nil, out_string = nil)
-
(String, nil)
-
Parameters:
-
out_string
(String, nil
) -- -
max_len
(Integer, nil
) --
Other tags:
- Api: - private
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
def read_enum(max_len)
-
(String)
-
Parameters:
-
max_len
(Integer, nil
) --
Other tags:
- Api: - private
def read_enum(max_len) ax_len eam.to_a.join eger << @stream.next while @buf.length < max_len .slice!(..max_len) topIteration m = nil lice!(0..)