Class: GmailExtractor::EmailHtmlFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/gmail_extractor/email_formatter/email_html_formatter.rb

Overview

Prints the output as html

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#printerObject

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


18
19
20
21
22
23
# File 'lib/gmail_extractor/email_formatter/email_html_formatter.rb', line 18

def footer
  result = "</body></html>"

  @printer << result
  @printer.close
end

#headerObject



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