Class: Propaganda::Renderer
- Inherits:
-
Object
- Object
- Propaganda::Renderer
- Defined in:
- lib/propaganda/renderer.rb
Instance Method Summary collapse
-
#initialize(verbose = false) ⇒ Renderer
constructor
A new instance of Renderer.
- #render(html, output, template = nil) ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(verbose = false) ⇒ Renderer
Returns a new instance of Renderer.
15 16 17 |
# File 'lib/propaganda/renderer.rb', line 15 def initialize(verbose=false) @verbose = verbose end |
Instance Method Details
#render(html, output, template = nil) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/propaganda/renderer.rb', line 23 def render(html, output, template=nil) template ||= 'default' stylesheet = File.join(File.dirname(__FILE__), '..', '..', 'templates', "#{template}.xsl") stylesheet = File.(stylesheet) tmp = Tempfile.new('fop') tmp << html tmp.flush tmp.close output = File.(output) invoke('-xml', tmp.path, '-xsl', stylesheet, '-pdf', output) ensure tmp.close rescue nil tmp = nil end |
#version ⇒ Object
19 20 21 |
# File 'lib/propaganda/renderer.rb', line 19 def version invoke('-v') end |