Module: Comparable

Defined in:
lib/core_extensions/comparable.rb

Overview

This method was introduced in ruby 2.4, however this patch will allow this feature to be available in older versions fo ruby

Instance Method Summary collapse

Instance Method Details

#clamp(min, max) ⇒ Object



5
6
7
8
9
# File 'lib/core_extensions/comparable.rb', line 5

def clamp(min, max)
  return min if self < min
  return max if self > max
  self
end