Class: YouTubeG::GreedyChainIO

Inherits:
ChainIO
  • Object
show all
Defined in:
lib/youtube_g/chain_io.rb

Overview

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.

Constant Summary collapse

BIG_CHUNK =

500 kb

512 * 1024

Instance Attribute Summary

Attributes inherited from ChainIO

#autoclose

Instance Method Summary collapse

Methods inherited from ChainIO

#expected_length

Constructor Details

#initialize(*with_ios) ⇒ GreedyChainIO

Returns a new instance of GreedyChainIO.



62
63
64
# File 'lib/youtube_g/chain_io.rb', line 62

def initialize(*with_ios)
  __setobj__(YouTubeG::ChainIO.new(with_ios))
end

Instance Method Details

#read(any_buffer_size) ⇒ Object



66
67
68
# File 'lib/youtube_g/chain_io.rb', line 66

def read(any_buffer_size)
  __getobj__.read(BIG_CHUNK)
end