<commit_before>module RASN1
  module Types

    # ASN.1 SEQUENCE OF
    #
    # A SEQUENCE OF is an array of one ASN.1 type.
    #
    # == Use with {Primitive} types
    # To encode this ASN.1 example:
    #  Integers ::= SEQUENCE OF INTEGER
    # do:
    #  # Create a SEQUENCE OF INTEGER
    #  seqof = RASN1::Types::SequenceOf.new(:record, RASN1::Types::Integer)
    #  # Set integer values
    #  seqof.value << [1, 2, 3, 4]
    #
    # == Use with {Constructed} types
    # SEQUENCE OF may be used to create sequence of composed types. For example:
    #  composed_type = RASN1::Sequence.new(:comp)
    #  commposed_type.value = [RASN1::Types::Integer(:id),
    #                          RASN1::Types::OctetString(:data)]
    #  seqof = RASN1::SequenceOf.new(:comp, composed_type)
    #  seqof << [0, 'data0']
    #  seqof << [1, 'data1']
    #
    # == Use with {Model}
    # SEQUENCE OF may also be used with a Model type:
    #  class MyModel < RASN1::Model
    #    sequence :seq,
    #             content: [boolean(:bool), integer(:int)]
    #  end
    #
    #  seqof = RASN1::Types::SequenceOf.new(:record, MyModel)
    #  # set values
    #  seqof << { bool: true, int: 12 }
    #  seqof << { bool: false, int: 65535 }
    #  # Generate DER string
    #  der = seqof.to_der    # => String
    #  # parse 
    #  seqof.parse! der
    # @author <NAME>
    class SequenceOf < Constructed
      TAG = Sequence::TAG

      # @return [Class, Base]
      attr_reader :of_type

      # @param [Symbol, String] name name for this tag in grammar
      # @param [Class, Base] of_type base type for sequence of
      # @see Base#initialize
      def initialize(name, of_type, options={})
        super(name, options)
        @of_type = of_type
        @value = []
      end

      def initialize_copy(other)
        super
        @of_type = @of_type.dup
        @value.map! { |v| v.dup }
      end

      # Add an item to SEQUENCE OF
      # @param [Array,Hash, Model]
      def <<(obj)<commit_msg>Types::SequenceOf: update doc<commit_after>module RASN1
  module Types

    # ASN.1 SEQUENCE OF
    #
    # A SEQUENCE OF is an array of one ASN.1 type.
    #
    # == Use with {Primitive} types
    # To encode this ASN.1 example:
    #  Integers ::= SEQUENCE OF INTEGER
    # do:
    #  # Create a SEQUENCE OF INTEGER
    #  seqof = RASN1::Types::SequenceOf.new(:record, RASN1::Types::Integer)
    #  # Set integer values
    #  seqof.value << [1, 2, 3, 4]
    #
    # == Use with {Constructed} types
    # SEQUENCE OF may be used to create sequence of composed types. For example:
    #  composed_type = RASN1::Sequence.new(:comp)
    #  commposed_type.value = [RASN1::Types::Integer(:id),
    #                          RASN1::Types::OctetString(:data)]
    #  seqof = RASN1::SequenceOf.new(:comp, composed_type)
    #  seqof << [0, 'data0']
    #  seqof << [1, 'data1']
    #
    # == Use with {Model}
    # SEQUENCE OF may also be used with a Model type:
    #  class MyModel < RASN1::Model
    #    sequence :seq,
    #             content: [boolean(:bool), integer(:int)]
    #  end
    #
    #  seqof = RASN1::Types::SequenceOf.new(:record, MyModel)
    #  # set values
    #  seqof << { bool: true, int: 12 }
    #  seqof << { bool: false, int: 65535 }
    #  # Generate DER string
    #  der = seqof.to_der    # => String
    #  # parse 
    #  seqof.parse! der
    #
    # After parsing, a SEQUENCE OF may be accessed as an Array:
    #  seqof[0]                # => MyModel
    #  seqof[0][:bool].value   # => true
    #  seqof[0][:int].value    # => 12
    # @author <NAME>
    class SequenceOf < Constructed
      TAG = Sequence::TAG

      # @return [Class, Base]
      attr_reader :of_type

      # @param [Symbol, String] name name for this tag in grammar
      # @param [Class, Base] of_type base type for sequence of
      # @see Base#initialize
      def initialize(name, of_type, options={})
        super(name, options)
        @of_type = of_type
        @value = []
      end

      def initialize_copy(other)
        super
        @of_type = @of_type.dup
        @value.map! { |v| v.dup }
      end

      # Add an item to SEQUENCE OF
      # @param [Array,Hash, Model]
      def <<(obj)
{'fraction_non_alphanumeric': 0.12796771130104465, 'fraction_numerical': 0.014007597340930674, 'mean_word_length': 2.134672619047619, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4127027', 'n_tokens_mistral': 1509, 'n_tokens_neox': 1430, 'n_words': 392}