Class: RASN1::Types::BitString

Inherits:
Primitive show all
Defined in:
lib/rasn1/types/bit_string.rb

Overview

ASN.1 Bit String

Author:

  • Sylvain Daubert

Constant Summary collapse

TAG =
0x03

Constants inherited from Primitive

Primitive::ASN1_PC

Constants inherited from Base

RASN1::Types::Base::CLASSES, RASN1::Types::Base::INDEFINITE_LENGTH, RASN1::Types::Base::MAX_TAG

Instance Attribute Summary collapse

Attributes inherited from Base

#asn1_class, #default, #name, #value

Instance Method Summary collapse

Methods inherited from Base

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

Constructor Details

#initialize(name, options = {}) ⇒ BitString

Returns a new instance of BitString.

Parameters:

  • name (Symbol, String)

    name for this tag in grammar

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :class (Symbol)

    ASN.1 tag class. Default value is :universal

  • :optional (::Boolean)

    define this tag as optional. Default is false

  • :default (Object)

    default value for DEFAULT tag

  • :bit_length (Object)

    default bit_length value. Should be present if :default is set



20
21
22
23
24
25
26
27
28
# File 'lib/rasn1/types/bit_string.rb', line 20

def initialize(name, options={})
  super
  if @default
    if options[:bit_length].nil?
      raise ASN1Error, "TAG #@name: default bit length is not defined"
    end
    @default_bit_length = options[:bit_length]
  end
end

Instance Attribute Details

#bit_lengthInteger

Returns bit length of bit string.

Returns:

  • (Integer)

    bit length of bit string



10
11
12
# File 'lib/rasn1/types/bit_string.rb', line 10

def bit_length
  @bit_length
end