Okay thanks. I'm going to set my own constant.
The math looks good too, although I'm just using for boundary conditions.
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
Then I stumbled upon...Enumerable's
[x, y].min
So I ended up using a mix of both as I was looping through arrays in some cases to get the min/max.
I'm presuming the latter is slightly slower for just a check of two numbers.
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.