Have you looked at "Dr. Nic's Magic Models"? It's hosted on RubyForge at http://magicmodels.rubyforge.org/
While it doesn't do exactly what you ask, I bet you'd get a pretty good jump-start by seeing behind the curtain.
-Rob
Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com