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-0.23.2 lib/httpx/buffer.rb
httpx-0.23.1 lib/httpx/buffer.rb
httpx-0.23.0 lib/httpx/buffer.rb