class Grandfather::Wkhtmltopdf
Public Class Methods
new(parameters = nil)
click to toggle source
# File lib/grandfather/wkhtmltopdf.rb, line 4 def initialize(parameters = nil) @parameters = parameters end
Public Instance Methods
bin()
click to toggle source
# File lib/grandfather/wkhtmltopdf.rb, line 23 def bin @bin ||= "\"#{(`which wkhtmltopdf`).chomp}\"" end
command(filename)
click to toggle source
# File lib/grandfather/wkhtmltopdf.rb, line 19 def command(filename) [bin, @parameters, '--quiet', '-', "\"#{filename}\""].compact end
output_pdf(html, filename)
click to toggle source
# File lib/grandfather/wkhtmltopdf.rb, line 8 def output_pdf(html, filename) args = command(filename) invoke = args.join(' ') IO.popen(invoke, "wb+") do |pdf| pdf.puts(html) pdf.close_write pdf.gets(nil) end end