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 58 def capacity 59 @limit - @buffer.bytesize 60 end
initialize_dup(other)
[show source]
# File lib/httpx/buffer.rb 49 def initialize_dup(other) 50 super 51 @buffer = other.instance_variable_get(:@buffer).dup 52 end
shift!(fin)
[show source]
# File lib/httpx/buffer.rb 62 def shift!(fin) 63 @buffer = @buffer.byteslice(fin..-1) || "".b 64 end