Class: MailFetcher::GmailMessage

Inherits:
EmailMessage show all
Defined in:
lib/mail_fetcher/gmail_message.rb

Constant Summary collapse

CONTENT_TYPE_PLAIN =
/text\/plain/
CONTENT_TYPE_HTML =
/text\/html/

Constants inherited from EmailMessage

EmailMessage::URL_PATTERN

Instance Method Summary collapse

Methods inherited from EmailMessage

#initialize

Constructor Details

This class inherits a constructor from MailFetcher::EmailMessage

Instance Method Details

#html_bodyObject



16
17
18
# File 'lib/mail_fetcher/gmail_message.rb', line 16

def html_body
  find_part_by_content_type(CONTENT_TYPE_HTML).body.decoded
end

#html_urlsObject



20
21
22
# File 'lib/mail_fetcher/gmail_message.rb', line 20

def html_urls
  html_body.scan(%r{href="(#{URL_PATTERN.source})"}).flatten
end

#plain_text_bodyObject



8
9
10
# File 'lib/mail_fetcher/gmail_message.rb', line 8

def plain_text_body
  find_part_by_content_type(CONTENT_TYPE_PLAIN).body.decoded
end

#plain_text_urlsObject



12
13
14
# File 'lib/mail_fetcher/gmail_message.rb', line 12

def plain_text_urls
  plain_text_body.match(URL_PATTERN).to_a
end