Class: ProtocolBuffers::Field::BoolField

Inherits:
VarintField show all
Defined in:
lib/protocol_buffers/runtime/field.rb

Instance Attribute Summary

Attributes inherited from ProtocolBuffers::Field

#name, #otype, #tag

Instance Method Summary collapse

Methods included from WireFormats::VARINT

#wire_type

Methods inherited from NumericField

#max, #min

Methods inherited from ProtocolBuffers::Field

#add_methods_to, #check_valid, create, #initialize, #inspect_value, #repeated?

Instance Method Details

#check_value(value) ⇒ Object



485
# File 'lib/protocol_buffers/runtime/field.rb', line 485

def check_value(value); end

#default_valueObject



491
492
493
# File 'lib/protocol_buffers/runtime/field.rb', line 491

def default_value
  @opts[:default] || false
end

#deserialize(value) ⇒ Object



487
488
489
# File 'lib/protocol_buffers/runtime/field.rb', line 487

def deserialize(value)
  value != 0
end

#serialize(value) ⇒ Object



477
478
479
# File 'lib/protocol_buffers/runtime/field.rb', line 477

def serialize(value)
  value ? 1 : 0
end

#valid_type?(value) ⇒ Boolean

Returns:

  • (Boolean)


481
482
483
# File 'lib/protocol_buffers/runtime/field.rb', line 481

def valid_type?(value)
  value == true || value == false
end