Class: Tahweel::CLI::FileProcessor
- Inherits:
-
Object
- Object
- Tahweel::CLI::FileProcessor
- Defined in:
- lib/tahweel/cli/file_processor.rb
Overview
Processes a single file by orchestrating conversion/extraction and writing the output.
This class acts as the bridge between the CLI inputs and the core library logic. It determines the file type (PDF or Image), calls the appropriate processing method, and directs the results to the Writer.
Class Method Summary collapse
-
.process(file_path, options) {|Hash| ... } ⇒ void
Processes the given file according to the provided options.
Instance Method Summary collapse
-
#initialize(file_path, options) ⇒ FileProcessor
constructor
Initializes a new FileProcessor.
-
#process {|Hash| ... } ⇒ void
Executes the processing logic.
Constructor Details
#initialize(file_path, options) ⇒ FileProcessor
Initializes a new FileProcessor.
38 39 40 41 |
# File 'lib/tahweel/cli/file_processor.rb', line 38 def initialize(file_path, ) @file_path = file_path = end |
Class Method Details
.process(file_path, options) {|Hash| ... } ⇒ void
This method returns an undefined value.
Processes the given file according to the provided options.
}
32 |
# File 'lib/tahweel/cli/file_processor.rb', line 32 def self.process(file_path, , &) = new(file_path, ).process(&) |
Instance Method Details
#process {|Hash| ... } ⇒ void
This method returns an undefined value.
Executes the processing logic.
-
Ensures the output directory exists.
-
Checks if output files already exist to avoid redundant processing.
-
Detects if the input is a PDF or an image.
-
Runs the appropriate conversion/extraction pipeline.
-
Writes the results to the configured formats.
}
59 60 61 62 63 64 65 |
# File 'lib/tahweel/cli/file_processor.rb', line 59 def process(&) ensure_output_directory_exists return if all_outputs_exist? pdf? ? process_pdf(&) : process_image end |