class HTTPX::Buffer

  1. lib/httpx/buffer.rb
Superclass: Object

Internal class to abstract a string buffer, by wrapping a string and providing the minimum possible API and functionality required.

buffer = Buffer.new(640)
buffer.full? #=> false
buffer << "aa"
buffer.capacity #=> 638

Methods

Public Class

  1. new

Public Instance

  1. capacity
  2. full?
  3. limit
  4. shift!

Attributes

limit [R]

Public Class methods

new(limit)
[show source]
   # File lib/httpx/buffer.rb
33 def initialize(limit)
34   @buffer = "".b
35   @limit = limit
36 end

Public Instance methods

capacity()
[show source]
   # File lib/httpx/buffer.rb
42 def capacity
43   @limit - @buffer.bytesize
44 end
full?()
[show source]
   # File lib/httpx/buffer.rb
38 def full?
39   @buffer.bytesize >= @limit
40 end
shift!(fin)
[show source]
   # File lib/httpx/buffer.rb
46 def shift!(fin)
47   @buffer = @buffer.byteslice(fin..-1) || "".b
48 end