Class: DigestEmail::DigestItem

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

Instance Attribute Summary collapse

Attributes inherited from DigestElement

#children

Instance Method Summary collapse

Constructor Details

#initialize(item) ⇒ DigestItem

Returns a new instance of DigestItem.



8
9
10
11
12
13
14
# File 'lib/digest_email/digest_item.rb', line 8

def initialize(item)
  super()
  @list_title = item["list_title"]
  @title = item["title"]
  @image = item["image"]
  @body = item["body"]
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



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

def body
  @body
end

#imageObject

Returns the value of attribute image.



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

def image
  @image
end

#list_titleObject

Returns the value of attribute list_title.



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

def list_title
  @list_title
end

#titleObject

Returns the value of attribute title.



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

def title
  @title
end

Instance Method Details

#renderObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/digest_email/digest_item.rb', line 16

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

  html  = [
    render_image,
    "<div class=\"digest-email-item-content-container\">",
      "<div class=\"digest-email-item-title\">#{parsed_title}</div>",
      "<div class=\"digest-email-item-body\">#{parsed_body}</div>",
    "</div>"
  ]

  wrap html.join("\n")
end

#render_imageObject



31
32
33
34
35
36
# File 'lib/digest_email/digest_item.rb', line 31

def render_image
  html  = ["<div class=\"digest-email-item-image\">"]
  html << ["<img src=\"#{@image}\"/>"]
  html << ["</div>"]
  html.join("\n")
end

#wrap(inner) ⇒ Object



38
39
40
# File 'lib/digest_email/digest_item.rb', line 38

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