lib/ury_rapid/services/response_buffer.rb
# Adds a request for a given number of bytes to the request queue
#
# @api public
# @example Asking for 6 bytes.
#   @result = nil
#   reader.request(5) { |bytes| @result = bytes }
#   reader.add('abcdefghi')
#   @result
#   #=> 'abcde'
#
# @param num_bytes [Integer]  The number of bytes to ask for.
# @param front [Boolean]  If true, the request is added onto the front
#   of the queue, rather than the back.  This should be used for
#   nested requests.
#
# @yieldparam bytes [String]  The bytes received.
#
# @return [void]
Adds a request for a given number of bytes to the request queue
Adds a request for a given number of bytes to the request queue
def request(num_bytes, front = false, &block)
        @requests << [num_bytes, block] unless front
        @requests.unshift([num_bytes, block]) if front
        try_satisfy_requests unless @satisfying_requests
      end
def request ( num_bytes , front = false , & block ) @requests << [ num_bytes , block ] unless front @requests . unshift ( [ num_bytes , block ] ) if front try_satisfy_requests unless @satisfying_requests end
Adds a request for a given number of bytes to the request queue
Adds a request for a given number of bytes to the request queue
None
void
num_bytes
The number of bytes to ask for.
The number of bytes to ask for .
front
If true, the request is added onto the front of the queue, rather than the back. This should be used for nested requests.
If true the request is added onto the front of the queue rather than the back . This should be used for nested requests .
block
bytes
The bytes received.
The bytes received .
api
None
example
Asking for 6 bytes. @result = nil reader.request(5) { |bytes| @result = bytes } reader.add('abcdefghi') @result #=> 'abcde'
Asking for 6 bytes . @result = nil reader . request ( 5 ) { |bytes| @result = bytes } reader . add ( ' abcdefghi ' ) @result # = > ' abcde '