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.6.5 lib/protobuf/field/integer_field.rb
protobuf-2.6.4-java lib/protobuf/field/integer_field.rb
protobuf-2.6.4 lib/protobuf/field/integer_field.rb
protobuf-2.6.3-java lib/protobuf/field/integer_field.rb
protobuf-2.6.3 lib/protobuf/field/integer_field.rb
protobuf-2.6.2-java lib/protobuf/field/integer_field.rb
protobuf-2.6.2 lib/protobuf/field/integer_field.rb
protobuf-2.6.1-java lib/protobuf/field/integer_field.rb
protobuf-2.6.1 lib/protobuf/field/integer_field.rb
protobuf-2.6.0-java lib/protobuf/field/integer_field.rb
protobuf-2.6.0 lib/protobuf/field/integer_field.rb
protobuf-2.5.5-java lib/protobuf/field/integer_field.rb
protobuf-2.5.5 lib/protobuf/field/integer_field.rb
protobuf-2.5.4-java lib/protobuf/field/integer_field.rb
protobuf-2.5.4 lib/protobuf/field/integer_field.rb
protobuf-2.5.3 lib/protobuf/field/integer_field.rb
protobuf-2.5.2-java lib/protobuf/field/integer_field.rb
protobuf-2.5.2 lib/protobuf/field/integer_field.rb
protobuf-2.5.1 lib/protobuf/field/integer_field.rb
protobuf-2.5.0-java lib/protobuf/field/integer_field.rb