Class: Latexpdf::PdfGenerator
- Inherits:
-
Object
- Object
- Latexpdf::PdfGenerator
- Defined in:
- lib/latexpdf/pdf_generator.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#pdf_file ⇒ Object
readonly
Returns the value of attribute pdf_file.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Instance Method Summary collapse
- #cleanup ⇒ Object
- #content ⇒ Object
- #generate(target_file = nil) ⇒ Object
-
#initialize(tex) ⇒ PdfGenerator
constructor
A new instance of PdfGenerator.
- #pdf_exist? ⇒ Boolean
Constructor Details
#initialize(tex) ⇒ PdfGenerator
Returns a new instance of PdfGenerator.
11 12 13 |
# File 'lib/latexpdf/pdf_generator.rb', line 11 def initialize(tex) @template = tex end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
9 10 11 |
# File 'lib/latexpdf/pdf_generator.rb', line 9 def errors @errors end |
#pdf_file ⇒ Object (readonly)
Returns the value of attribute pdf_file.
9 10 11 |
# File 'lib/latexpdf/pdf_generator.rb', line 9 def pdf_file @pdf_file end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
9 10 11 |
# File 'lib/latexpdf/pdf_generator.rb', line 9 def template @template end |
Instance Method Details
#cleanup ⇒ Object
29 30 31 32 33 34 |
# File 'lib/latexpdf/pdf_generator.rb', line 29 def cleanup if File.directory?(build_path) FileUtils.remove_entry_secure(build_path) end @build_path = nil end |
#content ⇒ Object
40 41 42 |
# File 'lib/latexpdf/pdf_generator.rb', line 40 def content File.read(pdf_file) if pdf_exist? end |
#generate(target_file = nil) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/latexpdf/pdf_generator.rb', line 15 def generate(target_file=nil) write_tex Latexpdf.configuration.passes.times do run_tex end if pdf_exist? @pdf_file = target_pdf_file FileUtils.cp target_pdf_file, target_file if target_file else raise LatexpdfError.new "Tex failed: No PDF generated" end end |
#pdf_exist? ⇒ Boolean
36 37 38 |
# File 'lib/latexpdf/pdf_generator.rb', line 36 def pdf_exist? File.exist?(target_pdf_file) end |