lib/rtesseract/utils.rb in rtesseract-2.0.1 vs lib/rtesseract/utils.rb in rtesseract-2.1.0

- old
+ new

@@ -1,5 +1,7 @@ +require 'open3' + # RTesseract class RTesseract # Some utils methods module Utils # Remove files or Tempfile @@ -20,15 +22,23 @@ else File.unlink(file) end true end + + # Extract tesseract version number + def self.version_number + out, err, st = Open3.capture3(RTesseract.default_command, "--version") + + version = err.split("\n")[0].split(" ")[1].split('.')[0, 2].join('.') + Float(version) rescue nil + end end end # Hash class Hash # return the value and remove from hash def option(attr_name, default) delete(attr_name.to_s) || delete(attr_name) || default end -end \ No newline at end of file +end