Sha256: ef6b117ff51bf093132abfaa0230f9b98acd04a9ed8c74dffe9cfe8403a7210b
Contents?: true
Size: 790 Bytes
Versions: 4
Compression:
Stored size: 790 Bytes
Contents
module JsonTestData module NumberHelper def adjust_for_maximum(number:, maximum: nil, step_size: nil) return number unless (maximum && number >= maximum) num = !!step_size ? number - step_size : maximum - 1 adjust_for_maximum(number: num, maximum: maximum, step_size: step_size) end def adjust_for_minimum(number:, minimum: nil, step_size: nil) return number unless minimum && minimum >= number num = !!step_size ? number + step_size : minimum + 1 adjust_for_minimum(number: num, minimum: minimum, step_size: step_size) end def between(min:, max:, integer: false) return integer ? mean(min, max).round(0) : mean(min, max) end def mean(*numbers) numbers.inject(:+).to_f.quo(numbers.length) end end end
Version data entries
4 entries across 4 versions & 1 rubygems