Class: Protobuf::Field::Fixed64Field

Inherits:
Uint64Field show all
Defined in:
lib/protobuf/field/fixed64_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

BaseField::OBJECT_MODULE, BaseField::PACKED_TYPES

Instance Attribute Summary

Attributes inherited from BaseField

#default_value, #fully_qualified_name, #message_class, #name, #options, #rule, #tag, #type_class

Instance Method Summary collapse

Methods inherited from Uint64Field

#json_encode, max, min

Methods inherited from VarintField

#acceptable?, #coerce!, default, encode

Methods inherited from BaseField

#acceptable?, #coerce!, default, #default, #define_encode_to_stream!, #define_field_and_present_predicate!, #define_field_predicate!, #define_set_field!, #define_set_method!, #define_to_message_hash!, #define_value_from_values!, #define_value_from_values_for_serialization!, #deprecated?, #encode_to_stream, #enum?, #extension?, #field?, #field_and_present?, #fully_qualified_name_only!, #initialize, #map?, #message?, #optional?, #packed?, #repeated?, #repeated_message?, #required?, #set, #set_default_value!, #set_field, #set_map!, #set_repeated_message!, #tag_encoded, #to_message_hash, #to_message_hash_with_string_key, #to_s, #value_from_values, #value_from_values_for_serialization

Methods included from Logging

initialize_logger, #log_exception, #log_signature, #logger, #sign_message

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/fixed64_field.rb', line 11

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



17
18
19
20
# File 'lib/protobuf/field/fixed64_field.rb', line 17

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



22
23
24
# File 'lib/protobuf/field/fixed64_field.rb', line 22

def wire_type
  ::Protobuf::WireType::FIXED64
end