Class: RASN1::Types::Sequence
- Inherits:
-
Constructed
- Object
- Base
- Constructed
- RASN1::Types::Sequence
- Defined in:
- lib/rasn1/types/sequence.rb
Overview
ASN.1 sequence
A sequence is a collection of another ASN.1 types.
To encode this ASN.1 example:
Record ::= SEQUENCE {
id INTEGER,
room [0] INTEGER OPTIONAL,
house [1] IMPLICIT INTEGER DEFAULT 0
}
do:
seq = RASN1::Types::Sequence.new
seq.value = [
RASN1::Types::Integer.new
RASN1::Types::Integer.new(explicit: 0, optional: true),
RASN1::Types::Integer.new(implicit: 1, default: 0)
]
A sequence may also be used without value to not parse sequence content:
seq = RASN1::Types::Sequence.new(:seq)
seq.parse!(der_string)
seq.value # => String
Direct Known Subclasses
Constant Summary collapse
- TAG =
0x10
Constants inherited from Constructed
Constants inherited from Base
Base::CLASSES, Base::INDEFINITE_LENGTH, Base::MAX_TAG
Instance Attribute Summary
Attributes inherited from Base
#asn1_class, #default, #name, #value
Instance Method Summary collapse
-
#initialize(value_or_options = {}, options = {}) ⇒ Sequence
constructor
A new instance of Sequence.
- #initialize_copy(other) ⇒ Object
Methods inherited from Constructed
Methods inherited from Base
#==, #constructed?, encode_type, #explicit?, #implicit?, #inspect, #optional?, parse, #parse!, #primitive?, #tag, #tagged?, #to_der, #type, type, #value_size
Constructor Details
#initialize(value_or_options = {}, options = {}) ⇒ Sequence
Returns a new instance of Sequence.
31 32 33 34 |
# File 'lib/rasn1/types/sequence.rb', line 31 def initialize(={}, ={}) super @value ||= [] end |
Instance Method Details
#initialize_copy(other) ⇒ Object
36 37 38 39 |
# File 'lib/rasn1/types/sequence.rb', line 36 def initialize_copy(other) super @value = @value.map { |v| v.dup } end |