Class | Numeric |
In: |
lib/rbot/core/utils/extends.rb
|
Parent: | Object |
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
# File lib/rbot/core/utils/extends.rb, line 195 195: def clip(left,right=0) 196: raise ArgumentError unless left.kind_of?(Numeric) and right.kind_of?(Numeric) 197: l = [left,right].min 198: u = [left,right].max 199: return l if self < l 200: return u if self > u 201: return self 202: end