I’ve uploaded some example code on how to use Ruby to script DevonThink here.
github.com/tommysundstrom/DevonThink-helper