Class: MakeBook::Formats::PDF
- Inherits:
-
Object
- Object
- MakeBook::Formats::PDF
- Defined in:
- lib/makebook/formats/pdf.rb
Overview
PDF output format
Instance Attribute Summary collapse
-
#book ⇒ Object
readonly
Returns the value of attribute book.
-
#build ⇒ Object
readonly
Returns the value of attribute build.
Instance Method Summary collapse
- #build_file ⇒ Object
- #build_name ⇒ Object
-
#initialize(book, build, options = {}) ⇒ PDF
constructor
A new instance of PDF.
- #make ⇒ Object
- #stale? ⇒ Boolean
Constructor Details
#initialize(book, build, options = {}) ⇒ PDF
Returns a new instance of PDF.
7 8 9 10 11 |
# File 'lib/makebook/formats/pdf.rb', line 7 def initialize(book, build, = {}) @book = book @build = build @options = () end |
Instance Attribute Details
#book ⇒ Object (readonly)
Returns the value of attribute book.
5 6 7 |
# File 'lib/makebook/formats/pdf.rb', line 5 def book @book end |
#build ⇒ Object (readonly)
Returns the value of attribute build.
5 6 7 |
# File 'lib/makebook/formats/pdf.rb', line 5 def build @build end |
Instance Method Details
#build_file ⇒ Object
52 53 54 |
# File 'lib/makebook/formats/pdf.rb', line 52 def build_file Pathname("#{build_name}.pdf") end |
#build_name ⇒ Object
48 49 50 |
# File 'lib/makebook/formats/pdf.rb', line 48 def build_name build.root + book.root + book.name end |
#make ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/makebook/formats/pdf.rb', line 13 def make html = MakeBook::Formats::HTML.new(book, build) html.make if html.stale? kit = PDFKit.new(File.new(html.build_file), ) kit.to_file(build_file) end |
#stale? ⇒ Boolean
56 57 58 59 60 |
# File 'lib/makebook/formats/pdf.rb', line 56 def stale? book.source.mtime > build_file.mtime rescue Errno::ENOENT true end |