There is a real, non-trivial, example of template
genericity being used to express mathematical ideas
in the CGAL library:

http://www.cgal.org/Manual/doc_html/frameset/fsKernel.html
http://www.cgal.org/Manual/doc_html/frameset/fsBasic.html

How to do such things in Ruby in full generality (efficiency
aside)?  

I think the key idea is already familiar to C++ programmers;  
it is known as the 'Template traits' technique.

http://www.cantrip.org/traits.html

In Ruby, the implementation of traits would involve
actual methods passing actual arguments, rather than 
typedefs.  The traits class for each type is built to
know how that type satisfies the interface requirements.

-= Josh