Class: GmailExtractor::EmailHtmlFormatter
- Inherits:
-
Object
- Object
- GmailExtractor::EmailHtmlFormatter
- Defined in:
- lib/gmail_extractor/email_formatter/email_html_formatter.rb
Overview
Prints the output as html
Instance Attribute Summary collapse
-
#printer ⇒ Object
Returns the value of attribute printer.
Instance Method Summary collapse
- #email(email) ⇒ Object
- #footer ⇒ Object
- #header ⇒ Object
-
#initialize(printer) ⇒ EmailHtmlFormatter
constructor
A new instance of EmailHtmlFormatter.
- #label(label, limit) ⇒ Object
Constructor Details
#initialize(printer) ⇒ EmailHtmlFormatter
Returns a new instance of EmailHtmlFormatter.
8 9 10 |
# File 'lib/gmail_extractor/email_formatter/email_html_formatter.rb', line 8 def initialize(printer) @printer = printer end |
Instance Attribute Details
#printer ⇒ Object
Returns the value of attribute printer.
6 7 8 |
# File 'lib/gmail_extractor/email_formatter/email_html_formatter.rb', line 6 def printer @printer end |
Instance Method Details
#email(email) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/gmail_extractor/email_formatter/email_html_formatter.rb', line 25 def email(email) result = "" result << "<div class='email'>" result << "<div class='from'>#{email.from}</div>" result << "<div class='date'>#{email.date}</div>" result << "<div class='content'>#{email.content}</div>" result << "</div>" @printer << result end |
#footer ⇒ Object
18 19 20 21 22 23 |
# File 'lib/gmail_extractor/email_formatter/email_html_formatter.rb', line 18 def result = "</body></html>" @printer << result @printer.close end |
#header ⇒ Object
12 13 14 15 16 |
# File 'lib/gmail_extractor/email_formatter/email_html_formatter.rb', line 12 def header result = "<!doctype html><html><head><title>E-Mails</title><meta charset='utf-8'></head><body>" @printer << result end |
#label(label, limit) ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/gmail_extractor/email_formatter/email_html_formatter.rb', line 36 def label(label,limit) result = "" result << "<div class='label'>" result << "<div class='name'>#{label.name}</div>" result << "<div class='count'>#{label.count}</div>" result << "</div>" @printer << result end |