class Mail::PartsList
Attributes
parts[R]
Public Class Methods
new(*args)
click to toggle source
Calls superclass method
# File lib/mail/parts_list.rb, line 8 def initialize(*args) @parts = Array.new(*args) super @parts end
Public Instance Methods
attachments()
click to toggle source
# File lib/mail/parts_list.rb, line 24 def attachments Mail::AttachmentsList.new(@parts) end
collect() { |o| ... }
click to toggle source
# File lib/mail/parts_list.rb, line 28 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 43 def collect! raise NoMethodError, "#collect! is not defined, please call #collect and create a new PartsList" end
map!()
click to toggle source
# File lib/mail/parts_list.rb, line 39 def map! raise NoMethodError, "#map! is not defined, please call #collect and create a new PartsList" end
sort()
click to toggle source
# File lib/mail/parts_list.rb, line 47 def sort self.class.new(@parts.sort) end
sort!(order)
click to toggle source
# File lib/mail/parts_list.rb, line 51 def sort!(order) # stable sort should be used to maintain the relative order as the parts are added i = 0; sorted = @parts.sort_by do |a| # 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) << (i += 1) end @parts.clear sorted.each { |p| @parts << p } end
Private Instance Methods
get_order_value(part, order)
click to toggle source
# File lib/mail/parts_list.rb, line 66 def get_order_value(part, order) is_attachment = part.respond_to?(:attachment?) && part.attachment? has_content_type = part.respond_to?(:content_type) && !part[:content_type].nil? [is_attachment ? 1 : 0, (has_content_type ? order.index(part[:content_type].string.downcase) : nil) || 10000] end