Class: DigestEmail::DigestItem
- Inherits:
-
DigestElement
- Object
- DigestElement
- DigestEmail::DigestItem
- Defined in:
- lib/digest_email/digest_item.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#image ⇒ Object
Returns the value of attribute image.
-
#list_title ⇒ Object
Returns the value of attribute list_title.
-
#title ⇒ Object
Returns the value of attribute title.
Attributes inherited from DigestElement
Instance Method Summary collapse
-
#initialize(item) ⇒ DigestItem
constructor
A new instance of DigestItem.
- #render ⇒ Object
- #render_image ⇒ Object
- #wrap(inner) ⇒ Object
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
#body ⇒ Object
Returns the value of attribute body.
6 7 8 |
# File 'lib/digest_email/digest_item.rb', line 6 def body @body end |
#image ⇒ Object
Returns the value of attribute image.
6 7 8 |
# File 'lib/digest_email/digest_item.rb', line 6 def image @image end |
#list_title ⇒ Object
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 |
#title ⇒ Object
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
#render ⇒ Object
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_image ⇒ Object
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 |