Class: Protobuf::Field::Sfixed32Field
- Inherits:
-
Int32Field
- Object
- BaseField
- VarintField
- IntegerField
- Int32Field
- Protobuf::Field::Sfixed32Field
- Defined in:
- lib/protobuf/field/sfixed32_field.rb
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
#default, #default_value, #deprecated, #extension, #getter_method_name, #message_class, #name, #optional, #packed, #repeated, #required, #rule, #setter_method_name, #tag, #type_class
Instance Method Summary collapse
-
#decode(bytes) ⇒ Object
Public Instance Methods.
- #encode(value) ⇒ Object
- #wire_type ⇒ Object
Methods inherited from Int32Field
Methods inherited from VarintField
Methods inherited from BaseField
#acceptable?, default, #deprecated?, #enum?, #extension?, #initialize, #message?, #optional?, #packed?, #repeated?, #repeated_message?, #required?, #set, #to_s, #type, #warn_if_deprecated
Constructor Details
This class inherits a constructor from Protobuf::Field::BaseField
Instance Method Details
#decode(bytes) ⇒ Object
Public Instance Methods
11 12 13 14 15 |
# File 'lib/protobuf/field/sfixed32_field.rb', line 11 def decode(bytes) value = bytes.unpack('V').first value -= 0x1_0000_0000 if (value & 0x8000_0000).nonzero? value end |
#encode(value) ⇒ Object
17 18 19 |
# File 'lib/protobuf/field/sfixed32_field.rb', line 17 def encode(value) [value].pack('V') end |