Abbrev is a project mainly written in Ruby, it's free.
Algo Sample Code for Abbreviations
illustrative Ruby code to return all abbreviations for the given argument: e.g. for "abc": a, ab, abc, ac, b, c, bc