<commit_before>class Array

  # Translates the Array into SOAP compatible XML. See: Hash.to_soap_xml.
  def to_soap_xml(key, attributes = {})
    xml = Builder::XmlMarkup.new

    each_with_index do |item, index|
      attrs = tag_attributes attributes, index
      case item
        when Hash then xml.tag!(key, attrs) { xml << item.to_soap_xml }
        else           xml.tag!(key, attrs) { xml << item.to_soap_value }
      end
    end

    xml.target!
  end

private

  def tag_attributes(attributes, index)
    return {} if attributes.empty?

    attributes.inject({}) do |hash, (key, value)|
      value = value[index] if value.kind_of? Array
      hash.merge key => value
    end
  end

end<commit_msg>add rdoc for tag_attributes method<commit_after>class Array

  # Translates the Array into SOAP compatible XML. See: Hash.to_soap_xml.
  def to_soap_xml(key, attributes = {})
    xml = Builder::XmlMarkup.new

    each_with_index do |item, index|
      attrs = tag_attributes attributes, index
      case item
        when Hash then xml.tag!(key, attrs) { xml << item.to_soap_xml }
        else           xml.tag!(key, attrs) { xml << item.to_soap_value }
      end
    end

    xml.target!
  end

private

  # Takes a Hash of +attributes+ and the +index+ for which to return attributes
  # for duplicate tags.
  def tag_attributes(attributes, index)
    return {} if attributes.empty?

    attributes.inject({}) do |hash, (key, value)|
      value = value[index] if value.kind_of? Array
      hash.merge key => value
    end
  end

end
{'fraction_non_alphanumeric': 0.0964401294498382, 'fraction_numerical': 0.0, 'mean_word_length': 2.7524271844660193, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 18}, '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': '5802476', 'n_tokens_mistral': 486, 'n_tokens_neox': 479, 'n_words': 149}