<commit_before>module Mail
  class PartsList < Array
    
    def attachments
      Mail::AttachmentsList.new(self)
    end

    def collect
      if block_given?
        ary = PartsList.new
        each { |o| ary << yield(o) }
        ary
      else
        to_a
      end
    end

    alias :collect :map 
    
    def sort!(order)
      sorted = self.sort do |a, b|
        # OK, 10000 is arbitrary... if anyone actually wants to explicitly sort 10000 parts of a
        # single email message... please show me a use case and I'll put more work into this method,
        # in the meantime, it works :)
        a_order = order.index(a[:content_type].string.downcase) || 10000
        b_order = order.index(b[:content_type].string.downcase) || 10000
        a_order <=> b_order
      end
      self.clear
      sorted.each { |p| self << p }
    end
    
  end
end<commit_msg>Updating parts list to remove warning on over riding map<commit_after>module Mail
  class PartsList < Array
    
    def attachments
      Mail::AttachmentsList.new(self)
    end

    def collect
      if block_given?
        ary = PartsList.new
        each { |o| ary << yield(o) }
        ary
      else
        to_a
      end
    end
    
    undef :map
    alias_method :map, :collect

    def map!
      raise NoMethodError, "#map! is not defined, please call #collect and create a new PartsList"
    end
    
    def collect!
      raise NoMethodError, "#collect! is not defined, please call #collect and create a new PartsList"
    end
    
    def sort!(order)
      sorted = self.sort do |a, b|
        # OK, 10000 is arbitrary... if anyone actually wants to explicitly sort 10000 parts of a
        # single email message... please show me a use case and I'll put more work into this method,
        # in the meantime, it works :)
        a_order = order.index(a[:content_type].string.downcase) || 10000
        b_order = order.index(b[:content_type].string.downcase) || 10000
        a_order <=> b_order
      end
      self.clear
      sorted.each { |p| self << p }
    end
    
  end
end
{'fraction_non_alphanumeric': 0.08377467501203659, 'fraction_numerical': 0.019258545979778528, 'mean_word_length': 2.024745269286754, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 5, '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': '6502026', 'n_tokens_mistral': 669, 'n_tokens_neox': 610, 'n_words': 220}