Class: DigestEmail::DigestHeader

Inherits:
DigestElement show all
Defined in:
lib/digest_email/digest_header.rb

Instance Attribute Summary collapse

Attributes inherited from DigestElement

#children

Instance Method Summary collapse

Constructor Details

#initialize(header) ⇒ DigestHeader

Returns a new instance of DigestHeader.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/digest_email/digest_header.rb', line 8

def initialize(header)
  super()
  @title = header["title"]

  if header.has_key? "subtitle"
    @subtitle = header["subtitle"]
  else
    @subtitle = nil
  end

  if header.has_key? "subsubtitle"
    @subsubtitle = header["subsubtitle"]
  else
    @subsubtitle = nil
  end
end

Instance Attribute Details

#subsubtitleObject

Returns the value of attribute subsubtitle.



6
7
8
# File 'lib/digest_email/digest_header.rb', line 6

def subsubtitle
  @subsubtitle
end

#subtitleObject

Returns the value of attribute subtitle.



6
7
8
# File 'lib/digest_email/digest_header.rb', line 6

def subtitle
  @subtitle
end

#titleObject

Returns the value of attribute title.



6
7
8
# File 'lib/digest_email/digest_header.rb', line 6

def title
  @title
end

Instance Method Details

#render(items) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/digest_email/digest_header.rb', line 25

def render(items)
  parsed_title = Maruku.new(@title).to_html

  html = ["<div class=\"digest-email-header-title\">#{parsed_title}</div>"]

  unless @subtitle.nil?
    parsed_subtitle = Maruku.new(@subtitle).to_html
    html << ["<div class=\"digest-email-header-subtitle\">",
             parsed_subtitle,
             "</div>"]
  end

  unless @subsubtitle.nil?
    parsed_subsubtitle = Maruku.new(@subsubtitle).to_html
    html << ["<div class=\"digest-email-header-subsubtitle\">",
             parsed_subsubtitle,
             "</div>"]
  end

  # Contents List
  html << ["<div class=\"digest-email-dot-seperator\"></div>"]
  html << render_contents_list(items)
  html << ["<div class=\"digest-email-dot-seperator\"></div>"]

  wrap html.join("\n")
end

#render_contents_list(items) ⇒ Object



52
53
54
55
56
57
58
59
# File 'lib/digest_email/digest_header.rb', line 52

def render_contents_list(items)
  html =  ["<div class=\"digest-email-header-contents-list\">"]
  html << ["<ol>"]
  html << items.map { |item| "<li>#{Maruku.new(item.list_title).to_html}</li>" }.join
  html << ["</ol>"]
  html << ["</div>"]
  html.join
end

#wrap(inner) ⇒ Object



61
62
63
# File 'lib/digest_email/digest_header.rb', line 61

def wrap(inner)
  "<div class=\"digest-email-header\">#{inner}</div>"
end