Class: RASN2::Types::Boolean
- Defined in:
- lib/rasn2/types/boolean.rb
Overview
ASN.1 Boolean
Constant Summary collapse
- ID =
Boolean id value
0x01- DER_TRUE =
DER true value
0xff- DER_FALSE =
DER false value
0
Constants inherited from Primitive
Constants inherited from Base
RASN2::Types::Base::CLASSES, RASN2::Types::Base::CLASS_MASK, RASN2::Types::Base::INDEFINITE_LENGTH, RASN2::Types::Base::MULTI_OCTETS_ID
Instance Attribute Summary
Attributes inherited from Base
#asn1_class, #default, #model, #name, #options
Instance Method Summary collapse
-
#der_to_value(der, ber: false) ⇒ void
Make boolean value from DER/BER string.
- #void_value ⇒ false
Methods inherited from Base
#==, #asn1_class_to_s, #attributes, #bin2hex, #build, #can_build?, #check_id, #colorize, #common_inspect, constrained?, #constructed?, #der2name, #do_parse, #do_parse_explicit, #do_parse_explicit_with_tracing, #do_parse_with_tracing, #encode_identifier_octets, #encode_size, encoded_type, #explicit?, #explicit_type, #find_type, #get_data, #get_length, #id, #id2octets, #id_value, #implicit?, #indent, #initialize, #initialize_copy, #inspect, #inspect_value, #msg_type, #optional?, parse, #parse!, #pc_bit, #primitive?, #private?, #raise_id_error, #raise_on_indefinite_length, #self2name, #set_class, #set_default, #set_optional, #set_tag, #set_value, #specific_initializer, start_tracing, stop_tracing, #tag_id_to_integer, #tagged?, #to_der, #trace, #trace_real, #tracer, type, #type, #universal?, #unpack, #unsigned_to_chained_octets, #value, #value=, #value?, #value_size
Methods included from Helpers::Colorize
#begin_colorizer, #brace_surround, #colorize, #colorize_attribute, #colorize_bool, #colorize_class, #colorize_default, #colorize_enum, #colorize_id, #colorize_name, #colorize_nil, #colorize_value, #colorizer, #colorizer=, #end_colorizer, #int_with_hex, #length_specifier, #parens_hex
Constructor Details
This class inherits a constructor from RASN2::Types::Base
Instance Method Details
#der_to_value(der, ber: false) ⇒ void
This method returns an undefined value.
Make boolean value from DER/BER string.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rasn2/types/boolean.rb', line 28 def der_to_value(der, ber: false) raise ASN1Error, "tag #{@name}: BOOLEAN should have a length of 1" unless der.size == 1 bool = der.unpack1('C') case bool when DER_FALSE @value = false when DER_TRUE @value = true else raise ASN1Error, "tag #{@name}: bad value 0x%02x for BOOLEAN" % bool unless ber @value = true end end |
#void_value ⇒ false
17 18 19 |
# File 'lib/rasn2/types/boolean.rb', line 17 def void_value # rubocop:disable Naming/PredicateMethod false end |