Class: Protobuf::Field::BoolField
- Inherits:
-
VarintField
- Object
- BaseField
- VarintField
- Protobuf::Field::BoolField
- 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, #message_class, #name, #rule, #tag, #type
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from VarintField
Methods inherited from BaseField
#clear, #default_value, #descriptor, descriptor, #error_message, #get, #initialize, #initialized?, #max, #merge, #merge_array, #merge_value, #min, #optional?, #ready?, #repeated?, #required?, #set, #to_s, #typed_default_value
Constructor Details
This class inherits a constructor from Protobuf::Field::BaseField
Class Method Details
.default ⇒ Object
532 |
# File 'lib/protobuf/message/field.rb', line 532 def default; false end |
Instance Method Details
#acceptable?(val) ⇒ Boolean
535 536 537 538 |
# File 'lib/protobuf/message/field.rb', line 535 def acceptable?(val) raise TypeError unless [TrueClass, FalseClass].include? val.class true end |
#decode(bytes) ⇒ Object
540 541 542 |
# File 'lib/protobuf/message/field.rb', line 540 def decode(bytes) bytes.first == 1 end |
#encode(value) ⇒ Object
544 545 546 |
# File 'lib/protobuf/message/field.rb', line 544 def encode(value) [value ? 1 : 0].pack('C') end |