Class: Wkhtmltopdf
- Inherits:
-
Object
- Object
- Wkhtmltopdf
- Defined in:
- lib/wkhtmltopdf.rb
Instance Attribute Summary collapse
-
#html_file ⇒ Object
Returns the value of attribute html_file.
-
#optional_params ⇒ Object
Returns the value of attribute optional_params.
-
#params_string ⇒ Object
Returns the value of attribute params_string.
-
#pdf_file ⇒ Object
Returns the value of attribute pdf_file.
-
#source ⇒ Object
Returns the value of attribute source.
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(options) ⇒ Wkhtmltopdf
constructor
A new instance of Wkhtmltopdf.
Constructor Details
#initialize(options) ⇒ Wkhtmltopdf
Returns a new instance of Wkhtmltopdf.
5 6 7 8 9 10 11 |
# File 'lib/wkhtmltopdf.rb', line 5 def initialize() # @pdf_file = "#{options[:file_path]}/#{options[:pdf]}.pdf" @html_file = [:html_file] if .has_key?(:html_file) @source = [:source] if .has_key?(:source) @optional_params = [:wkhtmltopdf_options] if .has_key?(:wkhtmltopdf_options) create_params_string end |
Instance Attribute Details
#html_file ⇒ Object
Returns the value of attribute html_file.
3 4 5 |
# File 'lib/wkhtmltopdf.rb', line 3 def html_file @html_file end |
#optional_params ⇒ Object
Returns the value of attribute optional_params.
3 4 5 |
# File 'lib/wkhtmltopdf.rb', line 3 def optional_params @optional_params end |
#params_string ⇒ Object
Returns the value of attribute params_string.
3 4 5 |
# File 'lib/wkhtmltopdf.rb', line 3 def params_string @params_string end |
#pdf_file ⇒ Object
Returns the value of attribute pdf_file.
3 4 5 |
# File 'lib/wkhtmltopdf.rb', line 3 def pdf_file @pdf_file end |
#source ⇒ Object
Returns the value of attribute source.
3 4 5 |
# File 'lib/wkhtmltopdf.rb', line 3 def source @source end |
Instance Method Details
#generate ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/wkhtmltopdf.rb', line 13 def generate wkhtml_call = "wkhtmltopdf " if !@source.nil? wkhtml_call << "#{@source}" else wkhtml_call << "#{@html_file}" end wkhtml_call << " #{@params_string} - -q" return `#{wkhtml_call}` end |