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
Attributes
limit | [R] |
Public Class methods
new(limit)
[show source]
# File lib/httpx/buffer.rb 32 def initialize(limit) 33 @buffer = String.new("", encoding: Encoding::BINARY, capacity: limit) 34 @limit = limit 35 end
Public Instance methods
<<(chunk)
[show source]
# File lib/httpx/buffer.rb 37 def <<(chunk) 38 @buffer.append_as_bytes(chunk) 39 end
capacity()
[show source]
# File lib/httpx/buffer.rb 53 def capacity 54 @limit - @buffer.bytesize 55 end
shift!(fin)
[show source]
# File lib/httpx/buffer.rb 57 def shift!(fin) 58 @buffer = @buffer.byteslice(fin..-1) || "".b 59 end