Class: Sunabamail::Mail

Inherits:
Object
  • Object
show all
Defined in:
app/models/sunabamail/mail.rb

Instance Method Summary collapse

Constructor Details

#initialize(raw) ⇒ Mail

Returns a new instance of Mail.



2
3
4
# File 'app/models/sunabamail/mail.rb', line 2

def initialize(raw)
  @mail_message = Mail::Message.new(raw.encoded)
end

Instance Method Details

#attachmentsObject



34
# File 'app/models/sunabamail/mail.rb', line 34

def attachments = mail_message.attachments

#has_html?Boolean

Returns:

  • (Boolean)


12
13
14
15
16
# File 'app/models/sunabamail/mail.rb', line 12

def has_html?
  return true if html_part.present?

  "text/html" == mime_type
end

#has_text?Boolean

Returns:

  • (Boolean)


6
7
8
9
10
# File 'app/models/sunabamail/mail.rb', line 6

def has_text?
  return true if text_part.present?

  "text/plain" == mime_type
end

#html_bodyObject



26
27
28
29
30
31
32
# File 'app/models/sunabamail/mail.rb', line 26

def html_body
  if multipart?
    decoded_body(html_part)
  elsif "text/html" == mime_type
    decoded_body(mail_message)
  end
end

#text_bodyObject



18
19
20
21
22
23
24
# File 'app/models/sunabamail/mail.rb', line 18

def text_body
  if multipart?
    decoded_body(text_part)
  elsif "text/plain" == mime_type
    decoded_body(mail_message)
  end
end