Class: RASN1::Types::Null

Inherits:
Primitive show all
Defined in:
lib/rasn1/types/null.rb

Overview

ASN.1 Null

This type is a placeholder when a value is not mandatory (in a Choice, by example).

Constant Summary collapse

ID =

Null id value

0x05

Constants inherited from Primitive

Primitive::ASN1_PC

Constants inherited from Base

Base::CLASSES, Base::CLASS_MASK, Base::INDEFINITE_LENGTH, Base::MULTI_OCTETS_ID

Instance Attribute Summary

Attributes inherited from Base

#asn1_class, #default, #name, #options

Instance Method Summary collapse

Methods inherited from Base

#==, constrained?, #constructed?, #do_parse, #do_parse_explicit, #do_parse_explicit_with_tracing, #do_parse_with_tracing, encoded_type, #explicit?, #id, #implicit?, #initialize, #initialize_copy, #optional?, parse, #parse!, #primitive?, #specific_initializer, start_tracing, stop_tracing, #tagged?, #to_der, #trace, #type, type, #value, #value=, #value?, #value_size, #void_value

Constructor Details

This class inherits a constructor from RASN1::Types::Base

Instance Method Details

#can_build?Boolean

Build only if not optional

Returns:



29
30
31
# File 'lib/rasn1/types/null.rb', line 29

def can_build?
  !optional?
end

#der_to_value(der, ber: false) ⇒ void

This method returns an undefined value.

Check der string

Parameters:

  • der (String)
  • ber (::Boolean) (defaults to: false)

Raises:



38
39
40
41
42
43
# File 'lib/rasn1/types/null.rb', line 38

def der_to_value(der, ber: false) # rubocop:disable Lint/UnusedMethodArgument
  raise ASN1Error, 'NULL should not have content!' if der.length.positive?

  @no_value = true
  @value = void_value
end

#inspect(level = 0) ⇒ String

Parameters:

Returns:

  • (String)


21
22
23
24
25
# File 'lib/rasn1/types/null.rb', line 21

def inspect(level=0)
  str = common_inspect(level)[0..-2] # remove terminal ':'
  str << ' OPTIONAL' if optional?
  str
end