diff options
Diffstat (limited to 'lib/asn1kit/types/set.rb')
-rw-r--r-- | lib/asn1kit/types/set.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/asn1kit/types/set.rb b/lib/asn1kit/types/set.rb new file mode 100644 index 0000000..a2eaf1a --- /dev/null +++ b/lib/asn1kit/types/set.rb @@ -0,0 +1,28 @@ +# coding: ASCII-8BIT + +class ASN1Kit::Set < ASN1Kit::Type + asn1_tag :IMPLICIT, :UNIVERSAL, 17 + asn1_alias "SET" + + class << self + def [](*component_types) + ret = Class.new(self) + hash = component_types.map { |c| [c.name, c] }.to_h + ret.const_set(:COMPONENT_TYPES, hash) + ret + end + + private def inspect_inner + ctypes = self::COMPONENT_TYPES.values.map { |c| c.inspect }.join(", ") + "{ #{ctypes} }" + end + end + + def to_der + content = self.class::COMPONENT_TYPES.map { |name, type, opts| + next nil unless @value[name] + @value[name].to_der + }.compact.join + der_header(content.bytesize, :constructed) << content + end +end |