class Tubeclip::GreedyChainIO
Net::HTTP only can send chunks of 1024 bytes. This is very inefficient, so we have a spare IO that will send more when asked for 1024. We use delegation because the read call is recursive.
Constants
- BIG_CHUNK
Public Class Methods
new(*with_ios)
click to toggle source
# File lib/tubeclip/chain_io.rb, line 62 def initialize(*with_ios) __setobj__(Tubeclip::ChainIO.new(with_ios)) end
Public Instance Methods
length()
click to toggle source
# File lib/tubeclip/chain_io.rb, line 73 def length() __getobj__.expected_length end
read(size = BIG_CHUNK, dst_buf = nil)
click to toggle source
# File lib/tubeclip/chain_io.rb, line 66 def read(size = BIG_CHUNK, dst_buf = nil) src_buf = __getobj__.read(size) return nil unless src_buf copy_buf(src_buf, dst_buf) if dst_buf src_buf end
Private Instance Methods
copy_buf(src_buf, dst_buf)
click to toggle source
# File lib/tubeclip/chain_io.rb, line 79 def copy_buf(src_buf, dst_buf) dst_buf[0..-1] = '' dst_buf << src_buf end