Class: RASN1::Types::Constructed Abstract

Inherits:
Base
  • Object
show all
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

Author:

  • Sylvain Daubert

Direct Known Subclasses

Sequence, SequenceOf

Constant Summary collapse

ASN1_PC =

Constructed value

0x20

Constants inherited from Base

Base::CLASSES, Base::CLASS_MASK, Base::INDEFINITE_LENGTH, Base::MAX_TAG, Base::UNDUPPABLE_TYPES

Instance Attribute Summary

Attributes inherited from Base

#asn1_class, #default, #name, #value

Instance Method Summary collapse

Methods inherited from Base

#==, #constructed?, encode_type, #explicit?, #implicit?, #initialize, #initialize_copy, #optional?, parse, #parse!, #primitive?, #tag, #tagged?, #to_der, #type, type, #value_size

Constructor Details

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

Instance Method Details

#inspect(level = 0) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/rasn1/types/constructed.rb', line 13

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
        next if item.optional? && item.value.nil?

        str << "#{item.inspect(level)}\n"
      else
        str << '  ' * level + item.inspect + "\n"
      end
    end
    str
  else
    super
  end
end