# Rectification maps values to an interval treated either as a cycle or a # cutoff. # Adds recticiation to Numerics and their progeny class Numeric # Treats the interval between low and high as a cycle, returning the result # of wrapping the instance around this interval. def wrap_rectify(high=1,low=0) if (high != low) low,high = high,low if low > high diff = high-low self-diff*((self-low)/diff).floor else low end end # Treats the low and high as limits, returning low or high if the instance # is respectively below or above these values, or the instance if between # the two. def cut_rectify(high=1,low=0) low,high = high,low if low > high if (self < low) low elsif (self > high) high else self end end end