class MailFetcher::GmailMessage
Constants
- CONTENT_TYPE_HTML
- CONTENT_TYPE_PLAIN
Public Instance Methods
html_body()
click to toggle source
# File lib/mail_fetcher/gmail_message.rb, line 16 def html_body find_part_by_content_type(CONTENT_TYPE_HTML).body.decoded end
html_urls()
click to toggle source
# File lib/mail_fetcher/gmail_message.rb, line 20 def html_urls html_body.scan(%r{href="(#{URL_PATTERN.source})"}).flatten end
plain_text_body()
click to toggle source
# 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_urls()
click to toggle source
# File lib/mail_fetcher/gmail_message.rb, line 12 def plain_text_urls plain_text_body.match(URL_PATTERN).to_a end
Private Instance Methods
email()
click to toggle source
# File lib/mail_fetcher/gmail_message.rb, line 34 def email @email ||= begin raw_message = @connection.fetch(@message_id, 'RFC822.TEXT')[0].attr['RFC822.TEXT'] Mail.new(raw_message) end end
find_part_by_content_type(content_type)
click to toggle source
# File lib/mail_fetcher/gmail_message.rb, line 26 def find_part_by_content_type(content_type) if email.content_type =~ content_type email else email.parts.find { |p| p.content_type =~ content_type } end end