Class: GridifyPdf::Gridifier

Inherits:
Object
  • Object
show all
Defined in:
lib/gridify_pdf/gridifier.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input, cell_width: 50) ⇒ Gridifier

Returns a new instance of Gridifier.



7
8
9
10
# File 'lib/gridify_pdf/gridifier.rb', line 7

def initialize(input, cell_width: 50)
  @input = input
  @cell_width = cell_width
end

Instance Attribute Details

#cell_widthObject (readonly)

Returns the value of attribute cell_width.



5
6
7
# File 'lib/gridify_pdf/gridifier.rb', line 5

def cell_width
  @cell_width
end

#inputObject (readonly)

Returns the value of attribute input.



5
6
7
# File 'lib/gridify_pdf/gridifier.rb', line 5

def input
  @input
end

Instance Method Details

#gridifyObject



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/gridify_pdf/gridifier.rb', line 12

def gridify
  output_pdf = CombinePDF.new
  parsed_input.pages.each do |input_page|
    output_pdf << input_page
  end

  parsed_overlay = CombinePDF.parse(overlay_document.render)
  parsed_overlay.pages.slice(1..).each_with_index do |overlay_page, index|
    output_pdf.pages[index] << overlay_page
  end

  output_pdf.to_pdf
end