Sha256: 23ce74b0024af00698a3e57f9c0c7fa3ed01b27be07797c223809eccb10e982b

Contents?: true

Size: 223 Bytes

Versions: 3

Compression:

Stored size: 223 Bytes

Contents

Numeric.class_eval do
  def clamp min=nil, max=nil
    raise ArgumentError, "min must be <= max" if (min && max && (min > max))
    return min if min && (self < min)
    return max if max && (self > max)
    self
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gorillib-0.0.7 lib/gorillib/numeric/clamp.rb
gorillib-0.0.6 lib/gorillib/numeric/clamp.rb
gorillib-0.0.5 lib/gorillib/numeric/clamp.rb