Class: RTesseract::Command
- Inherits:
-
Object
- Object
- RTesseract::Command
- Defined in:
- lib/rtesseract/command.rb
Constant Summary collapse
- FIXED =
[:command, :psm, :oem, :lang, :tessdata_dir, :user_words, :user_patterns, :config_file]
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #configs ⇒ Object
- #full_command ⇒ Object
-
#initialize(source, output, options) ⇒ Command
constructor
A new instance of Command.
- #run ⇒ Object
Constructor Details
#initialize(source, output, options) ⇒ Command
Returns a new instance of Command.
9 10 11 12 13 |
# File 'lib/rtesseract/command.rb', line 9 def initialize(source, output, ) @source = source @output = output = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/rtesseract/command.rb', line 7 def end |
Instance Method Details
#configs ⇒ Object
15 16 17 |
# File 'lib/rtesseract/command.rb', line 15 def configs .to_h.map { |key, value| ['-c', "#{key}=#{value}"] unless FIXED.include?(key) }.compact end |
#full_command ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rtesseract/command.rb', line 19 def full_command command = [.command, @source, @output] command << ['--psm', .psm.to_s] if .psm command << ['--oem', .oem.to_s] if .oem command << ['-l', .lang] if .lang command << ['--tessdata_dir', .tessdata_dir] if .tessdata_dir command << ['--user_words', .user_words] if .user_words command << ['--user_patterns', .user_patterns] if .user_patterns command << configs command << .config_file.to_s if .config_file command.flatten end |
#run ⇒ Object
37 38 39 |
# File 'lib/rtesseract/command.rb', line 37 def run Open3.capture2e(*full_command) end |