Method: BBLib.loop_between
- Defined in:
- lib/bblib/core/util/number.rb
.loop_between(num, min, max) ⇒ Object
Similar to keep between but when a number exceeds max or is less than min it is looped to the min or max value respectively.
14 15 16 17 18 19 |
# File 'lib/bblib/core/util/number.rb', line 14 def self.loop_between(num, min, max) num = num.to_f unless num.is_a?(Numeric) num = max if min && num < min num = min if max && num > max num end |