Class: RASN1::Types::Constructed Abstract
- Defined in:
- lib/rasn1/types/constructed.rb
Overview
This class is abstract.
This class SHOULD be used as base class for all ASN.1 primitive types.
Base class for all ASN.1 constructed types
Direct Known Subclasses
Constant Summary collapse
- ASN1_PC =
Constructed value
0x20
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_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
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/rasn1/types/constructed.rb', line 16 def can_build? # rubocop:disable Metrics/CyclomaticComplexity return super unless @value.is_a?(Array) && optional? return false unless super @value.any? do |el| el.can_build? && ( el.primitive? || (el.value.respond_to?(:empty?) ? !el.value.empty? : !el.value.nil?)) end end |
#inspect(level = 0) ⇒ String
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/rasn1/types/constructed.rb', line 29 def inspect(level=0) case @value when Array str = common_inspect(level) str << "\n" level = level.abs + 1 @value.each do |item| case item when Base, Model, Wrapper str << "#{item.inspect(level)}\n" else str << ' ' * level str << "#{item.inspect}\n" end end str else super end end |