Class: PagesCore::FileEmbedder

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(files) ⇒ FileEmbedder

Returns a new instance of FileEmbedder.


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

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

Instance Attribute Details

#filesObject (readonly)

Returns the value of attribute files


5
6
7
# File 'lib/pages_core/file_embedder.rb', line 5

def files
  @files
end

Instance Method Details

#embed_file(file) ⇒ Object


19
20
21
22
23
24
25
26
# File 'lib/pages_core/file_embedder.rb', line 19

def embed_file(file)
  (
    :a,
    file.name,
    class: "file",
    href: file_path(file)
  )
end

#embed_files(embedded_files) ⇒ Object


15
16
17
# File 'lib/pages_core/file_embedder.rb', line 15

def embed_files(embedded_files)
  embedded_files.join(", ")
end

#to_htmlObject


11
12
13
# File 'lib/pages_core/file_embedder.rb', line 11

def to_html
  embed_files(files.map { |f| embed_file(f) })
end