aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1kit/types/set_of.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/asn1kit/types/set_of.rb')
-rw-r--r--lib/asn1kit/types/set_of.rb37
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/asn1kit/types/set_of.rb b/lib/asn1kit/types/set_of.rb
new file mode 100644
index 0000000..341810c
--- /dev/null
+++ b/lib/asn1kit/types/set_of.rb
@@ -0,0 +1,37 @@
+# coding: ASCII-8BIT
+
+class ASN1Kit::SetOf < ASN1Kit::Type
+ asn1_tag :IMPLICIT, :UNIVERSAL, 17
+ asn1_alias "SET OF"
+
+ class << self
+ def [](type)
+ ret = Class.new(self)
+ ret.const_set(:COMPONENT_TYPE, type)
+ ret
+ end
+
+ private def inspect_inner
+ self::COMPONENT_TYPE.inspect_abbrev
+ end
+ end
+
+ def to_der
+ content = @components.map { |c| c.to_der }.join
+ der_header(content.bytesize, :constructed) << content
+ end
+end
+
+module ASN1Kit::Internal::CompileSetOf
+ refine ASN1Kit::SetOf.singleton_class do
+ def _compile_fixup(state)
+ type = self::COMPONENT_TYPE
+ if type.is_a?(ASN1Kit::Internal::TypeReference)
+ type = type.unwrap(state)
+ state.resolve(type)
+ remove_const(:COMPONENT_TYPE)
+ const_set(:COMPONENT_TYPE, type)
+ end
+ end
+ end
+end