Sha256: 067bd7ff906d90e5628d41b7f7b7ffdf61592af4b75f69d8fd12bcc28390006f
Contents?: true
Size: 687 Bytes
Versions: 1
Compression:
Stored size: 687 Bytes
Contents
module BBLib # Used to keep any numeric number between a set of bounds. # Passing nil as min or max represents no bounds in that direction. # min and max are inclusive to the allowed bounds. def self.keep_between(num, min, max) num = num.to_f unless num.is_a?(Numeric) num = min if min && num < min num = max if max && num > max num end # 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. 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 end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bblib-0.4.1 | lib/number/bbnumber.rb |