Sha256: db49b8defa50892d655aeb30691f2c70fd900c6724786231d6f7e86231fc1163

Contents?: true

Size: 497 Bytes

Versions: 63

Compression:

Stored size: 497 Bytes

Contents

require 'protobuf/field/varint_field'

module Protobuf
  module Field
    class IntegerField < VarintField

      ##
      # Public Instance Methods
      #

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

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

    end
  end
end

Version data entries

63 entries across 63 versions & 5 rubygems

Version Path
protobuf-3.10.9 lib/protobuf/field/integer_field.rb
protobuf-3.10.8 lib/protobuf/field/integer_field.rb
protobuf-3.10.7 lib/protobuf/field/integer_field.rb
protobuf-3.10.6 lib/protobuf/field/integer_field.rb
protobuf-3.10.5 lib/protobuf/field/integer_field.rb
protobuf-3.10.4 lib/protobuf/field/integer_field.rb
protobuf-cucumber-3.10.8 lib/protobuf/field/integer_field.rb
protobuf-cucumber-3.10.7 lib/protobuf/field/integer_field.rb
protobuf-cucumber-3.10.6 lib/protobuf/field/integer_field.rb
protobuf-cucumber-3.10.5 lib/protobuf/field/integer_field.rb
protobuf-cucumber-3.10.4 lib/protobuf/field/integer_field.rb
protobuf-3.10.3 lib/protobuf/field/integer_field.rb
protobuf-3.10.2 lib/protobuf/field/integer_field.rb
protobuf-3.10.1 lib/protobuf/field/integer_field.rb
protobuf-3.10.0 lib/protobuf/field/integer_field.rb
protobuf-3.10.0.pre0 lib/protobuf/field/integer_field.rb
protobuf-3.9.0 lib/protobuf/field/integer_field.rb
protobuf-3.9.0.pre2 lib/protobuf/field/integer_field.rb
protobuf-3.9.0.pre lib/protobuf/field/integer_field.rb
protobuf-3.8.5 lib/protobuf/field/integer_field.rb