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.8.13 lib/protobuf/field/integer_field.rb
protobuf-2.8.12 lib/protobuf/field/integer_field.rb
protobuf-2.8.11 lib/protobuf/field/integer_field.rb
protobuf-2.8.10 lib/protobuf/field/integer_field.rb
protobuf-2.8.9 lib/protobuf/field/integer_field.rb
protobuf-2.8.8 lib/protobuf/field/integer_field.rb
protobuf-2.8.7 lib/protobuf/field/integer_field.rb
protobuf-2.8.6 lib/protobuf/field/integer_field.rb
protobuf-2.7.12 lib/protobuf/field/integer_field.rb
protobuf-2.8.5 lib/protobuf/field/integer_field.rb
protobuf-2.8.4 lib/protobuf/field/integer_field.rb
protobuf-2.8.3 lib/protobuf/field/integer_field.rb
protobuf-2.8.2 lib/protobuf/field/integer_field.rb
protobuf-2.8.1 lib/protobuf/field/integer_field.rb
protobuf-2.8.0 lib/protobuf/field/integer_field.rb
protobuf-2.8.0.beta9-java lib/protobuf/field/integer_field.rb
protobuf-2.8.0.beta9 lib/protobuf/field/integer_field.rb
protobuf-2.8.0.beta8-java lib/protobuf/field/integer_field.rb
protobuf-2.8.0.beta8 lib/protobuf/field/integer_field.rb
protobuf-2.8.0.beta6-java lib/protobuf/field/integer_field.rb