Class: PDFKit::WkHTMLtoPDF
- Inherits:
-
Object
- Object
- PDFKit::WkHTMLtoPDF
- Defined in:
- lib/pdfkit/wkhtmltopdf.rb
Constant Summary collapse
- REPEATABLE_OPTIONS =
%w[--allow --cookie --custom-header --post --post-file --run-script]
- SPECIAL_OPTIONS =
%w[cover toc]
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #error_handling? ⇒ Boolean
-
#initialize(options) ⇒ WkHTMLtoPDF
constructor
A new instance of WkHTMLtoPDF.
- #normalize_options ⇒ Object
- #options_for_command ⇒ Object
Constructor Details
#initialize(options) ⇒ WkHTMLtoPDF
Returns a new instance of WkHTMLtoPDF.
9 10 11 |
# File 'lib/pdfkit/wkhtmltopdf.rb', line 9 def initialize() @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'lib/pdfkit/wkhtmltopdf.rb', line 3 def @options end |
Instance Method Details
#error_handling? ⇒ Boolean
37 38 39 40 41 42 |
# File 'lib/pdfkit/wkhtmltopdf.rb', line 37 def error_handling? @options.key?('--ignore-load-errors') || # wkhtmltopdf v0.10.0 beta4 replaces ignore-load-errors with load-error-handling # https://code.google.com/p/wkhtmltopdf/issues/detail?id=55 %w(skip ignore).include?(@options['--load-error-handling']) end |
#normalize_options ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/pdfkit/wkhtmltopdf.rb', line 13 def # TODO(cdwort,sigmavirus24): Make this method idempotent in a future release so it can be called repeatedly = {} @options.each do |key, value| next if !value # The actual option for wkhtmltopdf normalized_key = normalize_arg key normalized_key = "--#{normalized_key}" unless SPECIAL_OPTIONS.include?(normalized_key) # If the option is repeatable, attempt to normalize all values if REPEATABLE_OPTIONS.include? normalized_key normalize_repeatable_value(normalized_key, value) do |normalized_unique_key, normalized_value| [normalized_unique_key] = normalized_value end else # Otherwise, just normalize it like usual [normalized_key] = normalize_value(value) end end @options = end |
#options_for_command ⇒ Object
44 45 46 |
# File 'lib/pdfkit/wkhtmltopdf.rb', line 44 def @options.to_a.flatten.compact end |