Class: GallerizeCli::Render

Inherits:
Object
  • Object
show all
Defined in:
lib/gallerize_cli/render.rb

Defined Under Namespace

Classes: View

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(directory) ⇒ Render

Returns a new instance of Render.



9
10
11
# File 'lib/gallerize_cli/render.rb', line 9

def initialize(directory)
  @directory = directory
end

Instance Attribute Details

#directoryObject

Returns the value of attribute directory.



7
8
9
# File 'lib/gallerize_cli/render.rb', line 7

def directory
  @directory
end

Instance Method Details

#output_fileObject



23
24
25
# File 'lib/gallerize_cli/render.rb', line 23

def output_file
  File.join(directory.output_path, 'index.html')
end

#performObject



13
14
15
16
17
18
19
20
21
# File 'lib/gallerize_cli/render.rb', line 13

def perform
  index = 1
  directory.images.each_slice(directory.config.images_per_page) do |images|
    file = File.join(directory.output_path, 'index.html')
    file = File.join(directory.output_path, "page-#{index}.html") if index != 1
    View.new(directory, file, {images: images, page_index: index}).render
    index += 1
  end
end