Class: OcrFile::Cli
- Inherits:
-
Object
- Object
- OcrFile::Cli
- Defined in:
- lib/ocr-file/cli.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(args) ⇒ Cli
constructor
A new instance of Cli.
- #invalid? ⇒ Boolean
- #valid? ⇒ Boolean
Constructor Details
#initialize(args) ⇒ Cli
Returns a new instance of Cli.
5 6 7 |
# File 'lib/ocr-file/cli.rb', line 5 def initialize(args) @args = args end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
3 4 5 |
# File 'lib/ocr-file/cli.rb', line 3 def args @args end |
Instance Method Details
#call ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/ocr-file/cli.rb', line 18 def call # TODO: Use ConsoleStyle::Functions # TODO: Heading and better CLI interface # Simple cli for now puts "OCR Tool © Jason Chalom 2022, Version: #{OcrFile::VERSION}" abort "File path, Save Folder Paths, and output type (pdf, txt) are required!" if invalid? # Using default config for now original_file_path = args[0] save_file_path = args[1] output_type = args[2] document = OcrFile::Document.new(original_file_path: original_file_path, save_file_path: save_file_path) if output_type.to_s.downcase.include?('pdf') document.to_pdf elsif output_type.to_s.downcase.include?('txt') || output_type.to_s.downcase.include?('text') document.to_text else # Display in console puts document.to_s end end |
#invalid? ⇒ Boolean
14 15 16 |
# File 'lib/ocr-file/cli.rb', line 14 def invalid? !valid? end |
#valid? ⇒ Boolean
9 10 11 12 |
# File 'lib/ocr-file/cli.rb', line 9 def valid? return true if args.size == 2 || args.size == 3 false end |