Class: RASN1::Types::Any
Overview
ASN.1 ANY: accepts any types
If ‘any#value` is `nil` and Any object is not Base#optional?, `any` will be encoded as a Null object.
Constant Summary
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
- #can_build? ⇒ Boolean
- #inspect(level = 0) ⇒ String
-
#parse!(der, ber: false) ⇒ Integer
Parse a DER string.
-
#to_der ⇒ String
DER-formated string.
- #trace ⇒ String
Methods inherited from Base
#==, constrained?, #constructed?, #der_to_value, #do_parse_explicit, #do_parse_explicit_with_tracing, #do_parse_with_tracing, encoded_type, #explicit?, #id, #implicit?, #initialize, #initialize_copy, #optional?, parse, #primitive?, #specific_initializer, start_tracing, stop_tracing, #tagged?, #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
30 31 32 |
# File 'lib/rasn1/types/any.rb', line 30 def can_build? value? || !optional? end |
#inspect(level = 0) ⇒ String
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/rasn1/types/any.rb', line 46 def inspect(level=0) str = common_inspect(level) str << if !value? 'NULL' elsif @value.is_a?(OctetString) || @value.is_a?(BitString) "#{@value.type}: #{value.value.inspect}" elsif @value.class < Base "#{@value.type}: #{value.value}" else value.to_s.inspect end end |
#parse!(der, ber: false) ⇒ Integer
Parse a DER string. This method updates object: Base#value will be a DER string.
39 40 41 42 |
# File 'lib/rasn1/types/any.rb', line 39 def parse!(der, ber: false) total_length, _data = do_parse(der, ber: ber) total_length end |
#to_der ⇒ String
Returns DER-formated string.
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rasn1/types/any.rb', line 17 def to_der if value? case @value when Base, Model @value.to_der else @value.to_s end else optional? ? '' : Null.new.to_der end end |
#trace ⇒ String
61 62 63 64 65 |
# File 'lib/rasn1/types/any.rb', line 61 def trace return trace_any if value? msg_type(no_id: true) << ' NONE' end |