class Datadog::Vendor::Multipart::Post::CompositeReadIO
Public Class Methods
new(*ios)
click to toggle source
Create a new composite-read IO from the arguments, all of which should respond to read
in a manner consistent with IO.
# File lib/ddtrace/vendor/multipart-post/multipart/post/composite_read_io.rb, line 23 def initialize(*ios) @ios = ios.flatten @index = 0 end
Public Instance Methods
read(length = nil, outbuf = nil)
click to toggle source
Read from IOs in order until `length` bytes have been received.
# File lib/ddtrace/vendor/multipart-post/multipart/post/composite_read_io.rb, line 29 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 == 0 end advance_io end (!got_result && length) ? nil : outbuf end
rewind()
click to toggle source
# File lib/ddtrace/vendor/multipart-post/multipart/post/composite_read_io.rb, line 46 def rewind @ios.each { |io| io.rewind } @index = 0 end
Private Instance Methods
advance_io()
click to toggle source
# File lib/ddtrace/vendor/multipart-post/multipart/post/composite_read_io.rb, line 57 def advance_io @index += 1 end
current_io()
click to toggle source
# File lib/ddtrace/vendor/multipart-post/multipart/post/composite_read_io.rb, line 53 def current_io @ios[@index] end