Class: Mail::PartsList
- Inherits:
-
Array
- Object
- Array
- Mail::PartsList
- Defined in:
- lib/mail/parts_list.rb
Instance Method Summary collapse
- #attachments ⇒ Object
- #collect ⇒ Object (also: #map)
- #collect! ⇒ Object
- #map! ⇒ Object
- #sort!(order) ⇒ Object
Instance Method Details
#attachments ⇒ Object
4 5 6 |
# File 'lib/mail/parts_list.rb', line 4 def Mail::AttachmentsList.new(self) end |
#collect ⇒ Object Also known as: map
8 9 10 11 12 13 14 15 16 |
# 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 |
#collect! ⇒ Object
25 26 27 |
# 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! ⇒ Object
21 22 23 |
# 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!(order) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/mail/parts_list.rb', line 29 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 |