Sha256: 5675b3ce4642784652f501cba5331056f3e2310eb203c874f972d4503b070c8e

Contents?: true

Size: 653 Bytes

Versions: 4

Compression:

Stored size: 653 Bytes

Contents

# frozen_string_literal: true

module RASN1
  module Types
    # ASN.1 Numeric String
    # @author Sylvain Daubert
    class NumericString < OctetString
      # NumericString id value
      ID = 18

      # Get ASN.1 type
      # @return [String]
      def self.type
        'NumericString'
      end

      private

      def value_to_der
        check_characters
        @value.to_s.b
      end

      def der_to_value(der, ber: false)
        super
        check_characters
      end

      def check_characters
        raise ASN1Error, "NUMERIC STRING #{@name}: invalid character: '#{$1}'" if @value.to_s =~ /([^0-9 ])/
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rasn1-0.13.1 lib/rasn1/types/numeric_string.rb
rasn1-0.13.0 lib/rasn1/types/numeric_string.rb
rasn1-0.12.1 lib/rasn1/types/numeric_string.rb
rasn1-0.12.0 lib/rasn1/types/numeric_string.rb