lib/polyfill/v2_4/comparable.rb in polyfill-0.6.0 vs lib/polyfill/v2_4/comparable.rb in polyfill-0.7.0
- old
+ new
@@ -1,9 +1,15 @@
-require_relative 'comparable/instance'
-
module Polyfill
module V2_4
module Comparable
- include Instance
+ def clamp(min, max)
+ if min > max
+ raise ArgumentError, 'min argument must be smaller than max argument'
+ end
+
+ return min if min > self
+ return max if max < self
+ self
+ end
end
end
end