Class: EasyIMAP::Message
- Inherits:
-
Object
- Object
- EasyIMAP::Message
- Defined in:
- lib/easy_imap/message.rb
Instance Method Summary collapse
-
#attachments ⇒ Object
An array of Attachment instances if this message is a multipart message with attachments, or an empty array otherwise.
-
#bcc ⇒ Object
An array of bcc e-mail addresses (as Strings).
-
#cc ⇒ Object
An array of cc e-mail addresses (as Strings).
-
#date ⇒ Object
The date this message was sent (an instance of Time).
-
#from ⇒ Object
An array of from e-mail addresses (as Strings).
-
#html ⇒ Object
Returns the text/html portion of this message (which could be the body, or one of the parts if the message is multipart), or the empty string if there is no text/html portion.
-
#in_reply_to ⇒ Object
The in_reply_to attribute (as a String).
-
#initialize(conn, uid) ⇒ Message
constructor
A new instance of Message.
-
#multipart? ⇒ Boolean
Returns true if this message is a multipart message.
-
#reply_to ⇒ Object
An array of reply_to e-mail addresses (as Strings).
-
#sender ⇒ Object
An array of sender e-mail addresses (as Strings).
-
#subject ⇒ Object
The subject of this message.
-
#text ⇒ Object
Returns the text/plain portion of this message (which could be the body, or one of the parts if the message is multipart), or the empty string if there is no text/plain portion.
-
#to ⇒ Object
An array of to e-mail addresses (as Strings).
Constructor Details
#initialize(conn, uid) ⇒ Message
Returns a new instance of Message.
7 8 9 10 |
# File 'lib/easy_imap/message.rb', line 7 def initialize(conn, uid) @conn = conn @uid = uid end |
Instance Method Details
#attachments ⇒ Object
An array of Attachment instances if this message is a multipart message with attachments, or an empty array otherwise.
83 84 85 86 87 88 89 |
# File 'lib/easy_imap/message.rb', line 83 def @attachments ||= if body.multipart? body.parts.find_all{|p| p.disposition == "attachment"}.map{|a| Attachment.new(a)} else [] end end |
#bcc ⇒ Object
An array of bcc e-mail addresses (as Strings).
48 49 50 |
# File 'lib/easy_imap/message.rb', line 48 def bcc (envelope[:bcc] || []).map {|a| address(a)} end |
#cc ⇒ Object
An array of cc e-mail addresses (as Strings).
43 44 45 |
# File 'lib/easy_imap/message.rb', line 43 def cc (envelope[:cc] || []).map {|a| address(a)} end |
#date ⇒ Object
The date this message was sent (an instance of Time).
13 14 15 |
# File 'lib/easy_imap/message.rb', line 13 def date Time.parse(envelope[:date]) end |
#from ⇒ Object
An array of from e-mail addresses (as Strings).
23 24 25 |
# File 'lib/easy_imap/message.rb', line 23 def from (envelope[:from] || []).map {|a| address(a)} end |
#html ⇒ Object
Returns the text/html portion of this message (which could be the body, or one of the parts if the message is multipart), or the empty string if there is no text/html portion.
75 76 77 78 |
# File 'lib/easy_imap/message.rb', line 75 def html html = find_part("text/html") html ? html.body : "" end |
#in_reply_to ⇒ Object
The in_reply_to attribute (as a String).
53 54 55 |
# File 'lib/easy_imap/message.rb', line 53 def in_reply_to envelope[:in_reply_to] end |
#multipart? ⇒ Boolean
Returns true if this message is a multipart message.
58 59 60 |
# File 'lib/easy_imap/message.rb', line 58 def multipart? body.multipart? end |
#reply_to ⇒ Object
An array of reply_to e-mail addresses (as Strings).
33 34 35 |
# File 'lib/easy_imap/message.rb', line 33 def reply_to (envelope[:reply_to] || []).map{|a| address(a)} end |
#sender ⇒ Object
An array of sender e-mail addresses (as Strings).
28 29 30 |
# File 'lib/easy_imap/message.rb', line 28 def sender (envelope[:sender] || []).map{|a| address(a)} end |
#subject ⇒ Object
The subject of this message.
18 19 20 |
# File 'lib/easy_imap/message.rb', line 18 def subject envelope[:subject] end |
#text ⇒ Object
Returns the text/plain portion of this message (which could be the body, or one of the parts if the message is multipart), or the empty string if there is no text/plain portion.
66 67 68 69 |
# File 'lib/easy_imap/message.rb', line 66 def text text = find_part("text/plain") text ? text.body : "" end |
#to ⇒ Object
An array of to e-mail addresses (as Strings).
38 39 40 |
# File 'lib/easy_imap/message.rb', line 38 def to (envelope[:to] || []).map {|a| address(a)} end |