Class: FlashFlow::Release::PdfDiffGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/flash_flow/release/pdf_diff_generator.rb

Constant Summary collapse

NUM_COLUMNS =
3
SPACE_BETWEEN =
10

Instance Method Summary collapse

Instance Method Details

#generate(compare_data, filename, threshold, verbose = true) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/flash_flow/release/pdf_diff_generator.rb', line 11

def generate(compare_data, filename, threshold, verbose=true)
  info = collect_comparison_info(compare_data, threshold)
  @orientation = :portrait
  Prawn::Document.generate(filename, page_layout: @orientation, margin: [10, 10, 10, 10]) do |pdf|
    set_dimensions(*pdf.bounds.top_right)
    generate_title_page(pdf)
    info.each do |comparison|
      add_comparison_to_pdf(pdf, comparison)
    end
    pdf.number_pages('<page> of <total>', { start_count_at: 1, align: :right, size: 12 })
    @num_pages = pdf.page_count
  end
  puts "Wrote #{@num_pages} pages to: #{filename}" if verbose
  filename
end