Sha256: 5436c2b6f47af0c2fbfc25ebdfec96930816f804ba9eff7aa9046b7f8661396e

Contents?: true

Size: 428 Bytes

Versions: 130

Compression:

Stored size: 428 Bytes

Contents

require 'protobuf/field/varint_field'

module Protobuf
  module Field
    class IntegerField < VarintField

      def encode(value)
        # original Google's library uses 64bits integer for negative value
        VarintField.encode(value & 0xffff_ffff_ffff_ffff)
      end

      def decode(value)
        value -= 0x1_0000_0000_0000_0000 if (value & 0x8000_0000_0000_0000).nonzero?
        value
      end

    end
  end
end

Version data entries

130 entries across 130 versions & 1 rubygems

Version Path
protobuf-2.0.3 lib/protobuf/field/integer_field.rb
protobuf-2.0.2 lib/protobuf/field/integer_field.rb
protobuf-2.0.1 lib/protobuf/field/integer_field.rb
protobuf-2.0.0 lib/protobuf/field/integer_field.rb
protobuf-2.0.0.rc6 lib/protobuf/field/integer_field.rb
protobuf-2.0.0.rc5 lib/protobuf/field/integer_field.rb
protobuf-2.0.0.rc4 lib/protobuf/field/integer_field.rb
protobuf-2.0.0.rc3 lib/protobuf/field/integer_field.rb
protobuf-2.0.0.rc2 lib/protobuf/field/integer_field.rb
protobuf-2.0.0.rc1 lib/protobuf/field/integer_field.rb