class Numeric

Extensions for the Numeric classes

Public Instance Methods

clip(left,right=0) click to toggle source

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 206
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