Class: Mailpeek::Email
- Inherits:
-
Object
- Object
- Mailpeek::Email
- Defined in:
- lib/mailpeek/email.rb
Overview
Public: Wrapper class for mail object
Instance Attribute Summary collapse
-
#attachments ⇒ Object
readonly
Returns the value of attribute attachments.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#html ⇒ Object
readonly
Returns the value of attribute html.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#mail ⇒ Object
readonly
Returns the value of attribute mail.
-
#message_id ⇒ Object
readonly
Returns the value of attribute message_id.
-
#position ⇒ Object
readonly
Returns the value of attribute position.
-
#subject ⇒ Object
readonly
Returns the value of attribute subject.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Instance Method Summary collapse
- #destroy ⇒ Object
-
#initialize(timestamp, mail) ⇒ Email
constructor
A new instance of Email.
- #match?(query) ⇒ Boolean
- #read ⇒ Object
- #read=(value) ⇒ Object
Constructor Details
#initialize(timestamp, mail) ⇒ Email
Returns a new instance of Email.
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/mailpeek/email.rb', line 11 def initialize(, mail) @id = @position = @mail = mail @to = mail[:to].addrs.map(&:format) @from = mail[:from].addrs.map(&:format) @subject = mail.subject @message_id = mail. @date = mail.date @attachments = [] mail.multipart? ? parse_parts : parse_body end |
Instance Attribute Details
#attachments ⇒ Object (readonly)
Returns the value of attribute attachments.
6 7 8 |
# File 'lib/mailpeek/email.rb', line 6 def @attachments end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
6 7 8 |
# File 'lib/mailpeek/email.rb', line 6 def date @date end |
#from ⇒ Object (readonly)
Returns the value of attribute from.
6 7 8 |
# File 'lib/mailpeek/email.rb', line 6 def from @from end |
#html ⇒ Object (readonly)
Returns the value of attribute html.
6 7 8 |
# File 'lib/mailpeek/email.rb', line 6 def html @html end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'lib/mailpeek/email.rb', line 6 def id @id end |
#mail ⇒ Object (readonly)
Returns the value of attribute mail.
6 7 8 |
# File 'lib/mailpeek/email.rb', line 6 def mail @mail end |
#message_id ⇒ Object (readonly)
Returns the value of attribute message_id.
6 7 8 |
# File 'lib/mailpeek/email.rb', line 6 def @message_id end |
#position ⇒ Object (readonly)
Returns the value of attribute position.
6 7 8 |
# File 'lib/mailpeek/email.rb', line 6 def position @position end |
#subject ⇒ Object (readonly)
Returns the value of attribute subject.
6 7 8 |
# File 'lib/mailpeek/email.rb', line 6 def subject @subject end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
6 7 8 |
# File 'lib/mailpeek/email.rb', line 6 def text @text end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
6 7 8 |
# File 'lib/mailpeek/email.rb', line 6 def to @to end |
Instance Method Details
#destroy ⇒ Object
29 30 31 |
# File 'lib/mailpeek/email.rb', line 29 def destroy FileUtils.rm_rf("#{Mailpeek.configuration.location}/#{id}") end |
#match?(query) ⇒ Boolean
25 26 27 |
# File 'lib/mailpeek/email.rb', line 25 def match?(query) subject&.match(query) || text&.match(query) || html&.match(query) end |
#read ⇒ Object
33 34 35 |
# File 'lib/mailpeek/email.rb', line 33 def read File.exist?(read_file_path) end |
#read=(value) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/mailpeek/email.rb', line 37 def read=(value) if value && !read FileUtils.touch(read_file_path) elsif !value && read File.delete(read_file_path) end end |