Class: Protobuf::Field::Fixed64Field

Inherits:
Uint64Field 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, #message_class, #name, #rule, #tag, #type

Instance Method Summary collapse

Methods inherited from Uint64Field

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?, #set, #to_s

Constructor Details

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

Instance Method Details

#decode(bytes) ⇒ Object



532
533
534
535
536
# File 'lib/protobuf/message/field.rb', line 532

def decode(bytes)
  # we don't use 'Q' for pack/unpack. 'Q' is machine-dependent.
  values = bytes.unpack('VV')
  values[0] + (values[1] << 32)
end

#encode(value) ⇒ Object



538
539
540
541
# File 'lib/protobuf/message/field.rb', line 538

def encode(value)
  # we don't use 'Q' for pack/unpack. 'Q' is machine-dependent.
  [value & 0xffff_ffff, value >> 32].pack('VV')
end

#wire_typeObject



528
529
530
# File 'lib/protobuf/message/field.rb', line 528

def wire_type
  WireType::FIXED64
end