Class: Cabbage::MimePart
- Inherits:
-
Object
- Object
- Cabbage::MimePart
- Defined in:
- lib/cabbage/email/mime_part.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#content_type ⇒ Object
Returns the value of attribute content_type.
-
#header ⇒ Object
Returns the value of attribute header.
-
#original_keys ⇒ Object
Returns the value of attribute original_keys.
-
#raw_source ⇒ Object
Returns the value of attribute raw_source.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #attachment? ⇒ Boolean
-
#initialize(raw_part) ⇒ MimePart
constructor
A new instance of MimePart.
- #keys ⇒ Object
- #method_missing(m, *args, &block) ⇒ Object
Constructor Details
#initialize(raw_part) ⇒ MimePart
Returns a new instance of MimePart.
4 5 6 7 8 9 10 |
# File 'lib/cabbage/email/mime_part.rb', line 4 def initialize(raw_part) @raw_source = raw_part @header = raw_part[:header] @original_keys = raw_part[:original_keys] @body = raw_part[:body] @content_type = @header[:content_type].split(";")[0].strip end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/cabbage/email/mime_part.rb', line 13 def method_missing(m, *args, &block) if @header.keys.include?(m.intern) @header[m.intern] else raise "undefined method in Cabbage::MimePart" end end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
11 12 13 |
# File 'lib/cabbage/email/mime_part.rb', line 11 def body @body end |
#content_type ⇒ Object
Returns the value of attribute content_type.
11 12 13 |
# File 'lib/cabbage/email/mime_part.rb', line 11 def content_type @content_type end |
#header ⇒ Object
Returns the value of attribute header.
11 12 13 |
# File 'lib/cabbage/email/mime_part.rb', line 11 def header @header end |
#original_keys ⇒ Object
Returns the value of attribute original_keys.
11 12 13 |
# File 'lib/cabbage/email/mime_part.rb', line 11 def original_keys @original_keys end |
#raw_source ⇒ Object
Returns the value of attribute raw_source.
11 12 13 |
# File 'lib/cabbage/email/mime_part.rb', line 11 def raw_source @raw_source end |
Instance Method Details
#[](key) ⇒ Object
21 22 23 |
# File 'lib/cabbage/email/mime_part.rb', line 21 def [](key) @header[key] end |
#attachment? ⇒ Boolean
29 30 31 32 33 34 35 |
# File 'lib/cabbage/email/mime_part.rb', line 29 def if @header.has_key?(:content_disposition) && @header[:content_disposition].start_with?("attachment") true else false end end |
#keys ⇒ Object
25 26 27 |
# File 'lib/cabbage/email/mime_part.rb', line 25 def keys @header.keys end |