class Faraday::CompositeReadIO
github.com/nicksieger/multipart-post/blob/master/lib/composite_io.rb<br>multipart-post gem.
Similar to, but not compatible with CompositeReadIO provided by the
def advance_io
def advance_io @index += 1 end
def close
-
(void)
-
def close @ios.each(&:close) end
def current_io
def current_io @ios[@index] end
def ensure_open_and_readable
def ensure_open_and_readable # Rubinius compatibility end
def initialize(*parts)
def initialize(*parts) @parts = parts.flatten @ios = @parts.map(&:to_io) @index = 0 end
def length
-
(Integer)
- sum of the lengths of all the parts
def length @parts.inject(0) { |sum, part| sum + part.length } end
def read(length = nil, outbuf = nil)
-
outbuf
(String, nil
) -- -
length
(Integer, nil
) --
def read(length = nil, outbuf = nil) got_result = false outbuf = outbuf ? (+outbuf).replace('') : +'' while (io = current_io) if (result = io.read(length)) got_result ||= !result.nil? result.force_encoding('BINARY') if result.respond_to?(:force_encoding) outbuf << result length -= result.length if length break if length&.zero? end advance_io end !got_result && length ? nil : outbuf end
def rewind
-
(void)
-
def rewind @ios.each(&:rewind) @index = 0 end