Class: FinchAPI::Util::ReadIOAdapter Private
- Inherits:
-
Object
- Object
- FinchAPI::Util::ReadIOAdapter
- Defined in:
- lib/finch-api/util.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
An adapter that satisfies the IO interface required by ‘::IO.copy_stream`
Instance Method Summary collapse
-
#initialize(stream, &blk) {|| ... } ⇒ ReadIOAdapter
constructor
private
A new instance of ReadIOAdapter.
- #read(max_len = nil, out_string = nil) ⇒ String? private
Constructor Details
#initialize(stream, &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.
432 433 434 435 436 |
# File 'lib/finch-api/util.rb', line 432 def initialize(stream, &blk) @stream = stream.is_a?(String) ? StringIO.new(stream) : stream @buf = String.new.b @blk = blk end |
Instance Method Details
#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.
408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 |
# File 'lib/finch-api/util.rb', line 408 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 |