Ruby K-means implementation which can be easily adjusted to X-means
https://news.ycombinator.com/item?id=11972180Actually there is a problem to find X-means on Ruby. This library is awesome because can be adjusted easily. You can redefine calcAverage, calcSum, calcDistanceSquared functions for your needs.
https://github.com/vaneyckt/kmeans-clustering/blob/master/example.rb