Class: Uktt::Pdf

Inherits:
Object
  • Object
show all
Defined in:
lib/uktt/pdf.rb

Overview

An object for producing PDF files of individual chapters in the Tariff

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Pdf

Returns a new instance of Pdf.



9
10
11
12
13
14
15
# File 'lib/uktt/pdf.rb', line 9

def initialize(opts = {})
  @chapter_id = opts[:chapter_id] || nil
  @filepath = opts[:filepath] || "#{Dir.pwd}/#{@chapter_id || 'cover'}.pdf"
  @currency = opts[:currency] || Uktt::PARENT_CURRENCY
  Uktt.configure(opts)
  @config = Uktt.config
end

Instance Attribute Details

#chapter_idObject

Returns the value of attribute chapter_id.



7
8
9
# File 'lib/uktt/pdf.rb', line 7

def chapter_id
  @chapter_id
end

#configObject

Returns the value of attribute config.



7
8
9
# File 'lib/uktt/pdf.rb', line 7

def config
  @config
end

Instance Method Details

#make_chapterObject



17
18
19
20
21
# File 'lib/uktt/pdf.rb', line 17

def make_chapter
  pdf = ExportChapterPdf.new(@config.merge(chapter_id: @chapter_id))
  pdf.save_as(@filepath)
  @filepath
end

#make_coverObject



32
33
34
35
36
# File 'lib/uktt/pdf.rb', line 32

def make_cover
  pdf = ExportCoverPdf.new
  pdf.save_as(@filepath)
  @filepath
end