Class: Mail::PartsList
- Inherits:
-
Array
- Object
- Array
- Mail::PartsList
- Defined in:
- lib/mail/parts_list.rb
Instance Attribute Summary collapse
-
#parts ⇒ Object
readonly
Returns the value of attribute parts.
Instance Method Summary collapse
- #attachments ⇒ Object
- #collect ⇒ Object (also: #map)
- #collect! ⇒ Object
-
#encode_with(coder) ⇒ Object
The #encode_with and #to_yaml methods are just implemented for the sake of backward compatibility ; the delegator does not correctly delegate these calls to the delegated object.
-
#initialize(*args) ⇒ PartsList
constructor
A new instance of PartsList.
- #map! ⇒ Object
- #sort ⇒ Object
- #sort!(order) ⇒ Object
-
#to_yaml(options = {}) ⇒ Object
:nodoc:.
Constructor Details
#initialize(*args) ⇒ PartsList
8 9 10 11 |
# File 'lib/mail/parts_list.rb', line 8 def initialize(*args) @parts = Array.new(*args) super @parts end |
Instance Attribute Details
#parts ⇒ Object (readonly)
Returns the value of attribute parts.
6 7 8 |
# File 'lib/mail/parts_list.rb', line 6 def parts @parts end |
Instance Method Details
#attachments ⇒ Object
24 25 26 |
# File 'lib/mail/parts_list.rb', line 24 def Mail::AttachmentsList.new(@parts) end |
#collect ⇒ Object Also known as: map
28 29 30 31 32 33 34 35 36 |
# 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 |
#collect! ⇒ Object
43 44 45 |
# 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 |
#encode_with(coder) ⇒ Object
The #encode_with and #to_yaml methods are just implemented for the sake of backward compatibility ; the delegator does not correctly delegate these calls to the delegated object
16 17 18 |
# File 'lib/mail/parts_list.rb', line 16 def encode_with(coder) # :nodoc: coder.represent_object(nil, @parts) end |
#map! ⇒ Object
39 40 41 |
# 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 ⇒ Object
47 48 49 |
# File 'lib/mail/parts_list.rb', line 47 def sort self.class.new(@parts.sort) end |
#sort!(order) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 |
# 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 |
#to_yaml(options = {}) ⇒ Object
:nodoc:
20 21 22 |
# File 'lib/mail/parts_list.rb', line 20 def to_yaml( = {}) # :nodoc: @parts.to_yaml() end |