Hacker News new | ask | show | jobs
by chris_vannoy 5743 days ago
With Ruby, anything you can call from the command line can work via system() (http://ruby-doc.org/core/classes/Kernel.html#M005971).

Alternatively, you can wrap into a gem with a C extension and call it with all the Ruby goodness you should expect (recommended route).

Pseudo-code (wordier than it need be):

class MyModel

  def self.ocr(file)

     result = system("my_ocr_prog", file.path)

     return result

  end
end

A good example of a gem with a C extension might be RMagick (http://github.com/rmagick/rmagick/tree/master/ext/RMagick/)