This is the Porter Stemming algorithm, ported to Ruby from the version coded up in Perl. It's easy to follow against the rules in the original paper in:
Porter, 1980, An algorithm for suffix stripping, Program, Vol. 14, no. 3, pp 130-137,
Taken from www.tartarus.org/~martin/PorterStemmer (Public Domain)