class RTesseract

def check_version!

def check_version!
  raise RTesseract::Error, 'Tesseract OCR 3.5 or later not installed' if RTesseract.tesseract_version < 3.05
end

def config

def config
  @config ||= RTesseract::Configuration.new(
    command: 'tesseract',
    debug_file: '/dev/null'
  )
end

def configure

def configure
  yield(config) if block_given?
end

def initialize(src = '', options = {})

def initialize(src = '', options = {})
  @source = src
  @config = RTesseract.config.merge(options)
  @errors = []
end

def reset_config!

def reset_config!
  @config = nil
end

def tesseract_version

def tesseract_version
  Open3.capture2e(RTesseract.config.command, '--version').first.to_s.match(/\d+.\d+/)[0].to_f
rescue Errno::ENOENT
  0
end

def to_box

def to_box
  Box.run(@source, @errors, @config)
end

def to_pdf

def to_pdf
  Pdf.run(@source, @errors, @config)
end

def to_s

Output value
def to_s
  Text.run(@source, @errors, @config)
end

def to_s_without_spaces

Remove spaces and break-lines
def to_s_without_spaces
  to_s.gsub(/\s/, '')
end

def to_tsv

def to_tsv
  Tsv.run(@source, @errors, @config)
end

def words

def words
  to_box.map { |word| word[:word] }
end