Jon A. Lambert wrote:
> I was suprised not to find min or max functions either
>
> looking for ...
>
> someclass#min(x,y)
> or
> x.min(y)
>
> I ended up using
> x < y ? x : y

It would be nice if there were, but there's a problem. Enumerables can
be comparable too. So #min and #max would name clash with Enumerable's
methods, and also with Date#min (for munutes).  It still might be
possible to do if one took arity into account though.

As It is Florian Gross provided Facets with #at_least and #at_most,
though to me those seem long winded for such a function. So I also
offer #clip and #cap.

  4.cap(5) #=> 4
  4.cap(3) #=> 3

  4.clip(5) #=> 5
  4.clip(3) #=> 4

  4.clip(5,7) #=> 5
  4.clip(3,5) #=> 4
  4.clip(1,3) #=> 3

T.