Class: Protobuf::Field::Sfixed32Field

Inherits:
Int32Field show all
Defined in:
lib/protobuf/message/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

Instance Attribute Summary

Attributes inherited from BaseField

#default, #default_value, #extension, #message_class, #name, #rule, #tag, #type

Instance Method Summary collapse

Methods inherited from Int32Field

max, min

Methods inherited from VarintField

#acceptable?, decode, default, encode

Methods inherited from BaseField

#acceptable?, default, descriptor, #descriptor, #initialize, #initialized?, #max, #merge, #min, #optional?, #packed?, #ready?, #repeated?, #required?, #to_s

Constructor Details

This class inherits a constructor from Protobuf::Field::BaseField

Instance Method Details

#decode(bytes) ⇒ Object



529
530
531
532
533
# File 'lib/protobuf/message/field.rb', line 529

def decode(bytes)
  value  = bytes.unpack('V').first
  value -= 0x1_0000_0000 if (value & 0x8000_0000).nonzero?
  value
end

#encode(value) ⇒ Object



535
536
537
# File 'lib/protobuf/message/field.rb', line 535

def encode(value)
  [value].pack('V')
end

#wire_type ⇒ Object



525
526
527
# File 'lib/protobuf/message/field.rb', line 525

def wire_type
  WireType::FIXED32
end