Class: WkhtmltopdfRunner::Cmd
- Inherits:
-
Object
- Object
- WkhtmltopdfRunner::Cmd
- Defined in:
- lib/wkhtmltopdf_runner/cmd.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(url:, file:, config:, options: {}) ⇒ Cmd
constructor
A new instance of Cmd.
- #run ⇒ Object
Constructor Details
#initialize(url:, file:, config:, options: {}) ⇒ Cmd
Returns a new instance of Cmd.
9 10 11 12 13 14 |
# File 'lib/wkhtmltopdf_runner/cmd.rb', line 9 def initialize(url:, file:, config:, options: {}) @url = url @file = file @config = config @options = config..merge() end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
7 8 9 |
# File 'lib/wkhtmltopdf_runner/cmd.rb', line 7 def config @config end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
7 8 9 |
# File 'lib/wkhtmltopdf_runner/cmd.rb', line 7 def file @file end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/wkhtmltopdf_runner/cmd.rb', line 7 def @options end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
7 8 9 |
# File 'lib/wkhtmltopdf_runner/cmd.rb', line 7 def url @url end |
Instance Method Details
#run ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/wkhtmltopdf_runner/cmd.rb', line 16 def run validate! debug_command! err, exit_status = Open3.popen3(*command) do |_stdin, _stdout, stderr, wait_thr| [stderr.read, wait_thr.value] end unless exit_status.success? raise WkhtmltopdfRunner::Error, "Failed to generate PDF. Status: #{exit_status.exitstatus} Error:\n#{err&.strip}" end true end |