class Uktt::Pdf

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

Attributes

chapter_id[RW]
config[RW]

Public Class Methods

new(opts = {}) click to toggle source
# 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

Public Instance Methods

config=(new_opts = {}) click to toggle source
# File lib/uktt/pdf.rb, line 23
def config=(new_opts = {})
  merged_opts = Uktt.config.merge(new_opts)
  Uktt.configure merged_opts
  @chapter_id = merged_opts[:chapter_id] || @chapter_id
  @filepath = merged_opts[:filepath] || @filepath
  @currency = merged_opts[:currency] || @currency
  @config = Uktt.config
end
make_chapter() click to toggle source
# 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_cover() click to toggle source
# File lib/uktt/pdf.rb, line 32
def make_cover
  pdf = ExportCoverPdf.new
  pdf.save_as(@filepath)
  @filepath
end