Class: RASN1::Types::BitString
- Defined in:
- lib/rasn1/types/bit_string.rb
Overview
ASN.1 Bit String
Constant Summary collapse
- TAG =
BitString tag value
0x03
Constants inherited from Primitive
Constants inherited from Base
RASN1::Types::Base::CLASSES, RASN1::Types::Base::CLASS_MASK, RASN1::Types::Base::INDEFINITE_LENGTH, RASN1::Types::Base::MAX_TAG, RASN1::Types::Base::UNDUPPABLE_TYPES
Instance Attribute Summary collapse
-
#bit_length ⇒ Object
Get bit length.
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) ⇒ String
Methods inherited from Base
#==, #constructed?, encode_type, #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.
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rasn1/types/bit_string.rb', line 25 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 @bit_length = opts[:bit_length] end |
Instance Attribute Details
#bit_length ⇒ Object
Get bit length
38 39 40 41 42 43 44 |
# File 'lib/rasn1/types/bit_string.rb', line 38 def bit_length if @value.nil? @default_bit_length else @bit_length end end |
Instance Method Details
#inspect(level = 0) ⇒ String
48 49 50 51 |
# File 'lib/rasn1/types/bit_string.rb', line 48 def inspect(level=0) str = common_inspect(level) str << " #{value.inspect} (bit length: #{bit_length})" end |