Rangify
This gem will add the rangify method to Ruby's Array class. The rangify method will produce appropriate ranges from the objects in the array.
Usage
Examples:
- 1,2,3,6,7,8].rangify = [1..3, 6..8
- 10..15, 16..20, 21, 22].rangify = [10..22
-
Assumes inclusive ranges (ie. 1..4) and range.first <= range.last.
Works with integers, dates and strings. However, all the objects in the array must be of the same class.