Class: TP::Publisher::PDF
- Inherits:
-
Object
- Object
- TP::Publisher::PDF
- Extended by:
- Forwardable
- Defined in:
- lib/tp/publisher/pdf.rb
Instance Attribute Summary collapse
-
#input_filename ⇒ Object
readonly
Returns the value of attribute input_filename.
Instance Method Summary collapse
- #document_options ⇒ Object
-
#initialize(input_filename, output_filename) ⇒ PDF
constructor
A new instance of PDF.
- #markdown ⇒ Object
- #new_page ⇒ Object
- #output_filename ⇒ Object
- #pdf ⇒ Object
- #presenter ⇒ Object
- #publish ⇒ Object
- #render_slide(slide) ⇒ Object
- #slides ⇒ Object
Constructor Details
#initialize(input_filename, output_filename) ⇒ PDF
Returns a new instance of PDF.
22 23 24 25 |
# File 'lib/tp/publisher/pdf.rb', line 22 def initialize(input_filename, output_filename) @input_filename = input_filename @output_filename = output_filename end |
Instance Attribute Details
#input_filename ⇒ Object (readonly)
Returns the value of attribute input_filename.
20 21 22 |
# File 'lib/tp/publisher/pdf.rb', line 20 def input_filename @input_filename end |
Instance Method Details
#document_options ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/tp/publisher/pdf.rb', line 61 def { page_layout: :landscape, optimize_objects: true, skip_page_creation: true } end |
#markdown ⇒ Object
41 42 43 |
# File 'lib/tp/publisher/pdf.rb', line 41 def markdown @markdown ||= File.read(input_filename) end |
#new_page ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/tp/publisher/pdf.rb', line 69 def new_page start_new_page fill_color '111111' canvas do fill_rectangle [bounds.left, bounds.top], bounds.width, bounds.height end fill_color 'EEEEEE' font "Helvetica" font_size 1.in end |
#output_filename ⇒ Object
53 54 55 |
# File 'lib/tp/publisher/pdf.rb', line 53 def output_filename @output_filename || "#{input_filename.split('.').first}.pdf" end |
#pdf ⇒ Object
57 58 59 |
# File 'lib/tp/publisher/pdf.rb', line 57 def pdf @pdf ||= Prawn::Document.new() end |
#presenter ⇒ Object
45 46 47 |
# File 'lib/tp/publisher/pdf.rb', line 45 def presenter @presenter ||= Presenter.new(markdown) end |
#publish ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/tp/publisher/pdf.rb', line 27 def publish .each do || () end render_file output_filename end |
#render_slide(slide) ⇒ Object
35 36 37 38 39 |
# File 'lib/tp/publisher/pdf.rb', line 35 def () new_page .render_pdf(pdf) end |
#slides ⇒ Object
49 50 51 |
# File 'lib/tp/publisher/pdf.rb', line 49 def presenter. end |