Class: RASN1::Types::NumericString

Inherits:
OctetString show all
Defined in:
lib/rasn1/types/numeric_string.rb

Overview

ASN.1 Numeric String

A NUMERIC STRING is an OctetString limited to numeric digit.

Examples:

Numeric string

ns = RASN1::Types::NumrericString.new(value: "123")
ns.to_der                     #=> "\x12\x03123"
RASN1.parse(ns.to_der).value  #=> "123"

Author:

  • Sylvain Daubert

  • LemonTree55

Constant Summary collapse

ID =

NumericString id value

18
INVALID_CHARS =

Invalid characters in NumericString

/([^0-9 ])/

Constants inherited from Primitive

Primitive::ASN1_PC

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from OctetString

#inspect

Methods inherited from Base

#==, #can_build?, constrained?, #constructed?, #do_parse, #do_parse_explicit, #do_parse_explicit_with_tracing, #do_parse_with_tracing, encoded_type, #explicit?, #id, #implicit?, #initialize, #initialize_copy, #inspect, #optional?, parse, #parse!, #primitive?, #specific_initializer, start_tracing, stop_tracing, #tagged?, #to_der, #trace, #type, #value, #value=, #value?, #value_size, #void_value

Constructor Details

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

Class Method Details

.typeString

Get ASN.1 type

Returns:

  • (String)


28
29
30
# File 'lib/rasn1/types/numeric_string.rb', line 28

def self.type
  'NumericString'
end

Instance Method Details

#der_to_value(der, ber: false) ⇒ void

This method returns an undefined value.

Make string value from der string

Parameters:

  • der (String)
  • ber (::Boolean) (defaults to: false)

Raises:



38
39
40
41
# File 'lib/rasn1/types/numeric_string.rb', line 38

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