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?, #der_to_value, #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
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rasn1/types/constructed.rb', line 22 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
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/rasn1/types/constructed.rb', line 35 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 |