Class: Protobug::Field::BoolField
Constant Summary
PACKABLE_WIRE_TYPES
Instance Attribute Summary
#adder, #cardinality, #clearer, #haser, #ivar, #json_name, #name, #number, #oneof, #setter
Instance Method Summary
collapse
Methods inherited from UInt64Field
#bit_length, #encoding, #signed, #wire_type
#json_encode_one
#adder_method_definition, #binary_decode, #binary_encode, #initialize, #json_decode, #json_encode, #json_key_encode, #method_definitions, #optional?, #packed?, #pretty_print, #proto3_optional?, #repeated?, #to_text
Instance Method Details
#binary_decode_one ⇒ Object
747
748
749
|
# File 'lib/protobug/field.rb', line 747
def binary_decode_one(*)
super != 0
end
|
#binary_encode_one(value, outbuf) ⇒ Object
751
752
753
|
# File 'lib/protobug/field.rb', line 751
def binary_encode_one(value, outbuf)
super(value ? 1 : 0, outbuf)
end
|
#default ⇒ Object
776
777
778
779
780
|
# File 'lib/protobug/field.rb', line 776
def default
return [] if repeated?
false
end
|
#json_decode_one(value, _ignore_unknown_fields, _registry) ⇒ Object
755
756
757
758
759
760
761
762
763
764
765
766
767
768
|
# File 'lib/protobug/field.rb', line 755
def json_decode_one(value, _ignore_unknown_fields, _registry)
case value
when TrueClass, FalseClass
value
when "true"
true
when "false"
false
when NilClass
UNSET
else
raise DecodeError, "expected boolean, got #{value.inspect}"
end
end
|
#validate!(value, message) ⇒ Object
770
771
772
773
774
|
# File 'lib/protobug/field.rb', line 770
def validate!(value, message)
raise InvalidValueError.new(message, self, value, "expected boolean") unless [true, false].include?(value)
super(value ? 1 : 0, message)
end
|