Is there a built-in way or a more elegant way of restricting a number num to upper/lower bounds in Ruby or in Rails?
e.g. something like:
def number_bounded (num, lower_bound, upper_bound) return lower_bound if num < lower_bound return upper_bound if num > upper_bound num end
class Range def clip(n) if cover?(n) n elsif n < min min else max end end end