Class: PagesCore::AttachmentEmbedder

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers::AssetTagHelper
Defined in:
lib/pages_core/attachment_embedder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attachments) ⇒ AttachmentEmbedder

Returns a new instance of AttachmentEmbedder.



9
10
11
# File 'lib/pages_core/attachment_embedder.rb', line 9

def initialize(attachments)
  @attachments = Array(attachments)
end

Instance Attribute Details

#attachmentsObject (readonly)

Returns the value of attribute attachments.



7
8
9
# File 'lib/pages_core/attachment_embedder.rb', line 7

def attachments
  @attachments
end

Instance Method Details

#embed_attachment(attachment) ⇒ Object



21
22
23
24
# File 'lib/pages_core/attachment_embedder.rb', line 21

def embed_attachment(attachment)
  tag.a(attachment.name, class: "file",
                         href: attachment_path(attachment))
end

#embed_attachments(embedded_attachments) ⇒ Object



17
18
19
# File 'lib/pages_core/attachment_embedder.rb', line 17

def embed_attachments(embedded_attachments)
  embedded_attachments.join(", ")
end

#to_htmlObject



13
14
15
# File 'lib/pages_core/attachment_embedder.rb', line 13

def to_html
  embed_attachments(attachments.map { |f| embed_attachment(f) })
end