class RTesseract
Constants
- VERSION
Attributes
config[R]
errors[R]
source[R]
Public Class Methods
check_version!()
click to toggle source
# File lib/rtesseract/check.rb, line 11 def check_version! raise RTesseract::Error, 'Tesseract OCR 3.5 or later not installed' if RTesseract.tesseract_version < 3.05 end
config()
click to toggle source
# File lib/rtesseract/configuration.rb, line 17 def config @config ||= RTesseract::Configuration.new( command: 'tesseract', debug_file: '/dev/null' ) end
configure() { |config| ... }
click to toggle source
# File lib/rtesseract/configuration.rb, line 24 def configure yield(config) if block_given? end
new(src = '', options = {})
click to toggle source
# File lib/rtesseract.rb, line 17 def initialize(src = '', options = {}) @source = src @config = RTesseract.config.merge(options) @errors = [] end
reset_config!()
click to toggle source
# File lib/rtesseract/configuration.rb, line 28 def reset_config! @config = nil end
tesseract_version()
click to toggle source
# File lib/rtesseract/check.rb, line 5 def tesseract_version Open3.capture2e(RTesseract.config.command, '--version').first.to_s.match(/\d+.\d+/)[0].to_f rescue Errno::ENOENT 0 end
Public Instance Methods
to_box()
click to toggle source
# File lib/rtesseract.rb, line 23 def to_box Box.run(@source, @errors, config) end
to_pdf()
click to toggle source
# File lib/rtesseract.rb, line 31 def to_pdf Pdf.run(@source, @errors, config) end
to_s()
click to toggle source
Output value
# File lib/rtesseract.rb, line 40 def to_s Text.run(@source, @errors, config) end
to_s_without_spaces()
click to toggle source
Remove spaces and break-lines
# File lib/rtesseract.rb, line 45 def to_s_without_spaces to_s.gsub(/\s/, '') end
to_tsv()
click to toggle source
# File lib/rtesseract.rb, line 35 def to_tsv Tsv.run(@source, @errors, config) end
words()
click to toggle source
# File lib/rtesseract.rb, line 27 def words to_box.map { |word| word[:word] } end