Class: Documentum::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/documentum/generator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(template_filename, output_dir, stylesheet_filenames: [], options: {}) ⇒ Generator

Returns a new instance of Generator.



6
7
8
9
10
# File 'lib/documentum/generator.rb', line 6

def initialize(template_filename, output_dir, stylesheet_filenames: [], options: {})
  @template_filename = template_filename
  @stylesheet_filenames = stylesheet_filenames
  @output_dir = output_dir
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/documentum/generator.rb', line 4

def options
  @options
end

#output_dirObject (readonly)

Returns the value of attribute output_dir.



4
5
6
# File 'lib/documentum/generator.rb', line 4

def output_dir
  @output_dir
end

#stylesheet_filenamesObject (readonly)

Returns the value of attribute stylesheet_filenames.



4
5
6
# File 'lib/documentum/generator.rb', line 4

def stylesheet_filenames
  @stylesheet_filenames
end

#template_filenameObject (readonly)

Returns the value of attribute template_filename.



4
5
6
# File 'lib/documentum/generator.rb', line 4

def template_filename
  @template_filename
end

Instance Method Details

#generate_pdf(markdown_filename) ⇒ Object



12
13
14
15
16
17
# File 'lib/documentum/generator.rb', line 12

def generate_pdf(markdown_filename)
  html = generate_html(markdown_filename)
  engine = PDFKit.new(html, page_size: "Letter")
  engine.stylesheets += @stylesheet_filenames
  engine.to_file(output_path(markdown_filename))
end