class Numeric
Extensions for the Numeric
classes
Public Instance Methods
Source
# File lib/rbot/core/utils/extends.rb, line 195 def clip(left,right=0) raise ArgumentError unless left.kind_of?(Numeric) and right.kind_of?(Numeric) l = [left,right].min u = [left,right].max return l if self < l return u if self > u return self end
This method forces a real number to be not more than a given positive number or not less than a given positive number, or between two any given numbers