Class: RASN1::Types::BitString
- Defined in:
- lib/rasn1/types/bit_string.rb
Overview
ASN.1 Bit String
Constant Summary collapse
- TAG =
0x03
Constants inherited from Primitive
Constants inherited from Base
RASN1::Types::Base::CLASSES, RASN1::Types::Base::INDEFINITE_LENGTH, RASN1::Types::Base::MAX_TAG
Instance Attribute Summary collapse
-
#bit_length ⇒ Integer
Bit length of bit string.
Attributes inherited from Base
#asn1_class, #default, #name, #value
Instance Method Summary collapse
-
#initialize(value_or_options = {}, options = {}) ⇒ BitString
constructor
A new instance of BitString.
- #inspect(level = 0) ⇒ Object
Methods inherited from Base
#==, #constructed?, #explicit?, #implicit?, #initialize_copy, #optional?, parse, #parse!, #primitive?, #tag, #tagged?, #to_der, type, #type, #value_size
Constructor Details
#initialize(options = {}) ⇒ BitString #initialize(value, options = {}) ⇒ BitString
Returns a new instance of BitString.
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rasn1/types/bit_string.rb', line 22 def initialize(={}, ={}) super opts = .is_a?(Hash) ? : if @default if opts[:bit_length].nil? raise ASN1Error, "TAG #@name: default bit length is not defined" end @default_bit_length = opts[:bit_length] end end |
Instance Attribute Details
#bit_length ⇒ Integer
Returns bit length of bit string.
10 11 12 |
# File 'lib/rasn1/types/bit_string.rb', line 10 def bit_length @bit_length end |
Instance Method Details
#inspect(level = 0) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/rasn1/types/bit_string.rb', line 33 def inspect(level=0) str = '' str << ' ' * level if level > 0 str << "#{name} " unless @name.nil? str << "#{type}: #{value.inspect} (bit length: #{bit_length})" end |