Sha256: 5d99199bd5acc8f0b0d16120f55d283a8f42ede7fe28305a553a26c24e75563d

Contents?: true

Size: 534 Bytes

Versions: 2

Compression:

Stored size: 534 Bytes

Contents

require 'stringio'

module Appdash
  class Buffer < ::StringIO

    def initialize
      super
      binmode
    end

    def push(packet)
      payload = packet.serialize_to_string
      write_uvarint payload.bytesize
      write payload
    end

    def bytesize
      string.bytesize
    end

    def reset
      truncate(0)
      rewind
    end

    private

      def write_uvarint(x)
        while x >= 0x80
          write ((x & 0xFF) | 0x80).chr
          x >>= 7
        end
        write (x & 0xFF).chr
      end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
appdash-0.6.3 lib/appdash/buffer.rb
appdash-0.6.2 lib/appdash/buffer.rb