Sha256: 9f311c5a1d061f8a3f692de8b57c7f7bf4c5b5b7e4eb0a526adb75cb670c9057

Contents?: true

Size: 665 Bytes

Versions: 23

Compression:

Stored size: 665 Bytes

Contents

# frozen_string_literal: true

require "forwardable"

module HTTPX
  class Buffer
    extend Forwardable

    def_delegator :@buffer, :<<

    def_delegator :@buffer, :to_s

    def_delegator :@buffer, :to_str

    def_delegator :@buffer, :empty?

    def_delegator :@buffer, :bytesize

    def_delegator :@buffer, :clear

    def_delegator :@buffer, :replace

    attr_reader :limit

    def initialize(limit)
      @buffer = "".b
      @limit = limit
    end

    def full?
      @buffer.bytesize >= @limit
    end

    def capacity
      @limit - @buffer.bytesize
    end

    def shift!(fin)
      @buffer = @buffer.byteslice(fin..-1) || "".b
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
httpx-1.2.0 lib/httpx/buffer.rb
httpx-1.1.5 lib/httpx/buffer.rb
httpx-1.1.4 lib/httpx/buffer.rb
httpx-1.1.3 lib/httpx/buffer.rb
httpx-1.1.2 lib/httpx/buffer.rb
httpx-1.1.1 lib/httpx/buffer.rb
httpx-1.1.0 lib/httpx/buffer.rb
httpx-1.0.2 lib/httpx/buffer.rb
httpx-0.24.7 lib/httpx/buffer.rb
httpx-1.0.1 lib/httpx/buffer.rb
httpx-1.0.0 lib/httpx/buffer.rb
httpx-0.24.6 lib/httpx/buffer.rb
httpx-0.24.5 lib/httpx/buffer.rb
httpx-0.24.4 lib/httpx/buffer.rb
httpx-0.24.3 lib/httpx/buffer.rb
httpx-0.24.2 lib/httpx/buffer.rb
httpx-0.24.1 lib/httpx/buffer.rb
httpx-0.24.0 lib/httpx/buffer.rb
httpx-0.23.4 lib/httpx/buffer.rb
httpx-0.23.3 lib/httpx/buffer.rb