Class: Protobuf::Field::IntegerField
- Inherits:
-
VarintField
- Object
- BaseField
- VarintField
- Protobuf::Field::IntegerField
- Defined in:
- lib/protobuf/field/integer_field.rb
Direct Known Subclasses
Constant Summary
Constants inherited from VarintField
VarintField::INT32_MAX, VarintField::INT32_MIN, VarintField::INT64_MAX, VarintField::INT64_MIN, VarintField::UINT32_MAX, VarintField::UINT64_MAX
Constants inherited from BaseField
Instance Attribute Summary
Attributes inherited from BaseField
#message_class, #name, #options, #rule, #tag, #type_class
Instance Method Summary collapse
-
#decode(value) ⇒ Object
Public Instance Methods.
- #encode(value) ⇒ Object
Methods inherited from VarintField
#acceptable?, default, encode, #wire_type
Methods inherited from BaseField
#acceptable?, #coerce!, default, #default, #default_value, #deprecated?, #enum?, #extension?, #getter, #initialize, #message?, #optional?, #packed?, #repeated?, #repeated_message?, #required?, #set, #setter, #to_s, #type, #warn_if_deprecated, #wire_type
Methods included from Logging
initialize_logger, #log_exception, #log_signature, #logger, logger, logger=, #sign_message
Constructor Details
This class inherits a constructor from Protobuf::Field::BaseField
Instance Method Details
#decode(value) ⇒ Object
Public Instance Methods
11 12 13 14 |
# File 'lib/protobuf/field/integer_field.rb', line 11 def decode(value) value -= 0x1_0000_0000_0000_0000 if (value & 0x8000_0000_0000_0000).nonzero? value end |
#encode(value) ⇒ Object
16 17 18 19 |
# File 'lib/protobuf/field/integer_field.rb', line 16 def encode(value) # original Google's library uses 64bits integer for negative value ::Protobuf::Field::VarintField.encode(value & 0xffff_ffff_ffff_ffff) end |