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::INDEFINITE_LENGTH, Base::MAX_TAG
Instance Attribute Summary
Attributes inherited from Base
#asn1_class, #default, #name, #value
Instance Method Summary collapse
- #inspect(level = 0) ⇒ Object
-
#parse!(der, ber: false) ⇒ Integer
Parse a DER string.
-
#to_der ⇒ String
DER-formated string.
Methods inherited from Base
#==, #constructed?, encode_type, #explicit?, #implicit?, #initialize, #initialize_copy, #optional?, parse, #primitive?, #tag, #tagged?, type, #type, #value_size
Constructor Details
This class inherits a constructor from RASN1::Types::Base
Instance Method Details
#inspect(level = 0) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/rasn1/types/any.rb', line 39 def inspect(level=0) str = '' str << ' ' * level if level > 0 str << "#{@name} " unless @name.nil? if @value.nil? str << "(ANY) NULL" elsif @value.is_a?(OctetString) or @value.is_a?(BitString) str << "(ANY) #{@value.type}: #{value.value.inspect}" elsif @value.class < Base str << "(ANY) #{@value.type}: #{value.value}" else str << "ANY: #{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.
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rasn1/types/any.rb', line 27 def parse!(der, ber: false) if der.nil? or der.empty? return 0 if optional? raise ASN1Error, "Expected ANY but get nothing" end total_length, = get_data(der, ber) @value = der[0, total_length] total_length end |