class PdfEditor::TableOfContents

Attributes

resources[R]

Public Instance Methods

body() click to toggle source
# File lib/pdf_editor/table_of_contents.rb, line 40
def body
  begin_page_count = 1 # TOC normally doesn't count itself as a page

  resources.inject(begin_page_count) do |page_location, resource|
    text "#{resource.name}........................#{page_location}"
    move_down 10 

    page_location + resource.page_count 
  end
end
call() click to toggle source
# File lib/pdf_editor/table_of_contents.rb, line 16
def call
  if resources.empty?
    raise PdfEditor::Errors::ResourcesEmptyError, 
          'You must have at least one resource to create a table of contents'
  end
  PdfEditor::Resource.new(
    create_tempfile {create_pdf}
  )
end
create_pdf() click to toggle source
# File lib/pdf_editor/table_of_contents.rb, line 26
def create_pdf
  update_pdf do 
    header
    body
  end
  to_pdf
end
header() click to toggle source
# File lib/pdf_editor/table_of_contents.rb, line 34
def header
  move_down 20
  text 'applicant_name', size: 40, align: :center
  move_down 50
end
post_init() click to toggle source
# File lib/pdf_editor/table_of_contents.rb, line 12
def post_init
  @resources = args.fetch(:resources, [])
end