Sha256: c32b2de50ad32424b2bd1a5b42f501d70d417ea089af0d92ec0d92af2fba5a08

Contents?: true

Size: 908 Bytes

Versions: 6

Compression:

Stored size: 908 Bytes

Contents

module RASN1
  module Types

    # @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
    class Constructed < Base
      # Constructed value
      ASN1_PC = 0x20

      def inspect(level=0)
        case @value
        when Array
          str = ''
          str << '  ' * level if level > 0
          str << "#{@name} " unless @name.nil?
          level = level.abs
          str << "#{type}:\n"
          level += 1
          @value.each do |item|
            case item
            when Base, Model
              next if item.optional? and item.value.nil?
              str << "#{item.inspect(level)}\n"
            else
              str <<  '  ' * level + item.inspect + "\n"
            end
          end
          str
        else
          super
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rasn1-0.6.8 lib/rasn1/types/constructed.rb
rasn1-0.6.7 lib/rasn1/types/constructed.rb
rasn1-0.6.6 lib/rasn1/types/constructed.rb
rasn1-0.6.5 lib/rasn1/types/constructed.rb
rasn1-0.6.4 lib/rasn1/types/constructed.rb
rasn1-0.6.3 lib/rasn1/types/constructed.rb