class Mail::PartsList - mail-2.5.4 Documentation

# class Mail::PartsList

### Public Instance Methods

attachments() click to toggle source

    # File lib/mail/parts_list.rb, line 4
    def attachments
      Mail::AttachmentsList.new(self)
    end

collect() { |o| ... } click to toggle source

    # File lib/mail/parts_list.rb, line 8
    def collect
      if block_given?
        ary = PartsList.new
        each { |o| ary << yield(o) }
        ary
      else
        to_a
      end
    end

Also aliased as: map
collect!() click to toggle source

    # File lib/mail/parts_list.rb, line 25
    def collect!
      raise NoMethodError, "#collect! is not defined, please call #collect and create a new PartsList"
    end

map()
Alias for: collect
map!() click to toggle source

    # File lib/mail/parts_list.rb, line 21
    def map!
      raise NoMethodError, "#map! is not defined, please call #collect and create a new PartsList"
    end

sort() click to toggle source
Calls superclass method

    # File lib/mail/parts_list.rb, line 29
    def sort
      self.class.new(super)
    end

sort!(order) click to toggle source

    # File lib/mail/parts_list.rb, line 33
    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 :)
        get_order_value(a, order) <=> get_order_value(b, order)
      end
      self.clear
      sorted.each { |p| self << p }
    end

### Private Instance Methods

get_order_value(part, order) click to toggle source

    # File lib/mail/parts_list.rb, line 46
    def get_order_value(part, order)
      if part.respond_to?(:content_type)
        order.index(part[:content_type].string.downcase) || 10000
      else
        10000
      end
    end