<commit_before># encoding: utf-8
module Protocop

  # Encapsulates behaviour for writing to a string of bytes that conforms to
  # the Protocol Buffer wire protocol.
  #
  # @since 0.0.0
  class Buffer

    # Constant for binary string encoding.
    BINARY = "BINARY"

    # @attribute [r] bytes The wrapped string of bytes.
    attr_reader :bytes

    # Check if this buffer is equal to the other object. Simply checks the
    # bytes against the other's bytes.
    #
    # @example Check buffer equality.
    #   buffer == other
    #
    # @param [ Object ] other The object to check against.
    #
    # @return [ true, false ] If the buffer is equal to the object.
    #
    # @since 0.0.0
    def ==(other)
      bytes == other.bytes
    end

    # Instantiate a new buffer.
    #
    # @example Instantiate the buffer.
    #   Protocop::Buffer.new
    #
    # @since 0.0.0
    def initialize
      @bytes = "".force_encoding(BINARY)
    end

    # Read a boolen from the buffer, removing the byte from the buffer in the
    # process.
    #
    # @example Read a boolean from the buffer.
    #   buffer.read_boolean
    #
    # @return [ true, false ] value The boolean value.
    #
    # @see https://developers.google.com/protocol-buffers/docs/encoding
    #
    # @since 0.0.0
    def read_boolean
      read(1).ord != 0
    end

    # Read a 64bit double from the buffer, removing the bytes from the buffer
    # in the # process.
    #
    # @example Read a double from the buffer.
    #   buffer.read_double
    #
    # @return [ Float ] value The double value.
    #
    # @see https://developers.google.com/protocol-buffers/docs/encoding
    #
    # @since 0.0.0
    def read_double
      read(8).unpack("E")[0]
    end

    # Read a fixed size 32 bit integer from the buffer (little endian).
    #
    # @example Read the fixed 32 bit value.
    #   buffer.read_fixed32
    #
    # @return [ Integer ] The integer value.
    #
    # @see https://developers.google.com/protocol-buffers/docs/encoding
    #
    # @since 0.0.0
    def read_fixed32
      read(4).unpack("V")[0]
    end

    # Read a fixed size 64 bit integer from the buffer (little endian).
    #
    # @example Read the fixed 64 bit value.
    #   buffer.read_fixed64
    #
    # @return [ Integer ] The integer value.
    #
    # @see https://developers.google.com/protocol-buffers/docs/encoding
    #
    # @since 0.0.0
    def read_fixed64
      values = read(8).unpack("VV")
      values[0] + (values[1] << 32)
    end

    def read_float
      read(4).unpack("e")[0]
    end

    def read_int32
      read_int64
    end

    def read_int64<commit_msg>Add read_float rdoc<commit_after># encoding: utf-8
module Protocop

  # Encapsulates behaviour for writing to a string of bytes that conforms to
  # the Protocol Buffer wire protocol.
  #
  # @since 0.0.0
  class Buffer

    # Constant for binary string encoding.
    BINARY = "BINARY"

    # @attribute [r] bytes The wrapped string of bytes.
    attr_reader :bytes

    # Check if this buffer is equal to the other object. Simply checks the
    # bytes against the other's bytes.
    #
    # @example Check buffer equality.
    #   buffer == other
    #
    # @param [ Object ] other The object to check against.
    #
    # @return [ true, false ] If the buffer is equal to the object.
    #
    # @since 0.0.0
    def ==(other)
      bytes == other.bytes
    end

    # Instantiate a new buffer.
    #
    # @example Instantiate the buffer.
    #   Protocop::Buffer.new
    #
    # @since 0.0.0
    def initialize
      @bytes = "".force_encoding(BINARY)
    end

    # Read a boolen from the buffer, removing the byte from the buffer in the
    # process.
    #
    # @example Read a boolean from the buffer.
    #   buffer.read_boolean
    #
    # @return [ true, false ] value The boolean value.
    #
    # @see https://developers.google.com/protocol-buffers/docs/encoding
    #
    # @since 0.0.0
    def read_boolean
      read(1).ord != 0
    end

    # Read a 64bit double from the buffer, removing the bytes from the buffer
    # in the process.
    #
    # @example Read a double from the buffer.
    #   buffer.read_double
    #
    # @return [ Float ] value The double value.
    #
    # @see https://developers.google.com/protocol-buffers/docs/encoding
    #
    # @since 0.0.0
    def read_double
      read(8).unpack("E")[0]
    end

    # Read a fixed size 32 bit integer from the buffer (little endian),
    # removing the bytes from the buffer in the process.
    #
    # @example Read the fixed 32 bit value.
    #   buffer.read_fixed32
    #
    # @return [ Integer ] The integer value.
    #
    # @see https://developers.google.com/protocol-buffers/docs/encoding
    #
    # @since 0.0.0
    def read_fixed32
      read(4).unpack("V")[0]
    end

    # Read a fixed size 64 bit integer from the buffer (little endian),
    # removing the bytes from the buffer in the process.
    #
    # @example Read the fixed 64 bit value.
    #   buffer.read_fixed64
    #
    # @return [ Integer ] The integer value.
    #
    # @see https://developers.google.com/protocol-buffers/docs/encoding
    #
    # @since 0.0.0
    def read_fixed64
      values = read(8).unpack("VV")
      values[0] + (values[1] << 32)
    end

    # Read a 32bit float from the buffer, removing the bytes from the buffer
    # in the process.
    #
    # @example Read a float from the buffer.
    #   buffer.read_float
    #
    # @return [ Float ] value The float value.
    #
    # @see https://developers.google.com/protocol-buffers/docs/encoding
    #
    # @since 0.0.0
    def read_float
      read(4).unpack("e")[0]
    end

    def read_int32
      read_int64
    end

    def read_int64
{'fraction_non_alphanumeric': 0.09958071278825996, 'fraction_numerical': 0.02148846960167715, 'mean_word_length': 2.150798018712163, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 9, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '623294', 'n_tokens_mistral': 1903, 'n_tokens_neox': 1803, 'n_words': 585}