Class: PdfCover::Converter
- Inherits:
-
Object
- Object
- PdfCover::Converter
- Defined in:
- lib/pdf_cover/converter.rb
Defined Under Namespace
Classes: CommandFailedError, CommandNotFoundError, InvalidOption
Constant Summary collapse
- DEFAULT_FORMAT =
NOTE: Update the generate_jpegs.sh script when changing these values
"jpeg".freeze
- DEFAULT_QUALITY =
85- DEFAULT_RESOLUTION =
300- DEFAULT_ANTIALIASING =
4- COMMAND_EXECUTION_SUCCESS_CODE =
0- COMMAND_NOT_FOUND_CODE =
127
Instance Method Summary collapse
- #converted_file ⇒ Object
-
#initialize(file, options = {}) ⇒ Converter
constructor
A new instance of Converter.
Constructor Details
#initialize(file, options = {}) ⇒ Converter
Returns a new instance of Converter.
32 33 34 35 |
# File 'lib/pdf_cover/converter.rb', line 32 def initialize(file, = {}) @file = file () end |
Instance Method Details
#converted_file ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/pdf_cover/converter.rb', line 39 def converted_file parameters = build_parameters(file_path, device) stdout_str, stderr_str, status = execute_command("gs #{parameters}") case status when COMMAND_EXECUTION_SUCCESS_CODE then destination_file when COMMAND_NOT_FOUND_CODE then fail CommandNotFoundError else fail CommandFailedError.new(stdout_str, stderr_str) end rescue => e destination_file.close raise e end |