Class: Tahweel::Ocr
- Inherits:
-
Object
- Object
- Tahweel::Ocr
- Defined in:
- lib/tahweel/ocr.rb
Overview
The main entry point for Optical Character Recognition (OCR). This class acts as a factory/strategy context, delegating the actual extraction logic to a specific processor.
Constant Summary collapse
- AVAILABLE_PROCESSORS =
[:google_drive].freeze
Class Method Summary collapse
-
.extract(file_path, processor: :google_drive) ⇒ String
Convenience method to extract text using a specific processor.
Instance Method Summary collapse
-
#extract(file_path) ⇒ String
Extracts text from the file using the configured processor.
-
#initialize(processor: :google_drive) ⇒ Ocr
constructor
Initializes the OCR engine with a specific processor strategy.
Constructor Details
#initialize(processor: :google_drive) ⇒ Ocr
Initializes the OCR engine with a specific processor strategy.
29 30 31 32 33 34 |
# File 'lib/tahweel/ocr.rb', line 29 def initialize(processor: :google_drive) @processor = case processor when :google_drive then Processors::GoogleDrive.new else raise ArgumentError, "Unknown processor: #{processor}" end end |
Class Method Details
.extract(file_path, processor: :google_drive) ⇒ String
Convenience method to extract text using a specific processor.
23 |
# File 'lib/tahweel/ocr.rb', line 23 def self.extract(file_path, processor: :google_drive) = new(processor: processor).extract(file_path) |
Instance Method Details
#extract(file_path) ⇒ String
Extracts text from the file using the configured processor.
40 |
# File 'lib/tahweel/ocr.rb', line 40 def extract(file_path) = @processor.extract(file_path) |