Sha256: a6d8ddb373deaea578b23fdb5dbb0efc547d6ad26e2ebffec3dec62f76fe9eee

Contents?: true

Size: 263 Bytes

Versions: 10

Compression:

Stored size: 263 Bytes

Contents

module JsonTestData
  module NumberHelper
    def between(min:, max:, integer: false)
      return integer ? mean(min, max).round(0) : mean(min, max)
    end

    private

    def mean(*numbers)
      numbers.inject(:+).to_f.quo(numbers.length)
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
json_test_data-1.2.0 lib/json_test_data/data_structures/helpers/number_helper.rb
json_test_data-1.1.3 lib/json_test_data/data_structures/helpers/number_helper.rb
json_test_data-1.1.2 lib/json_test_data/data_structures/helpers/number_helper.rb
json_test_data-1.1.1 lib/json_test_data/data_structures/helpers/number_helper.rb
json_test_data-1.1.0 lib/json_test_data/data_structures/helpers/number_helper.rb
json_test_data-1.0.0 lib/json_test_data/data_structures/helpers/number_helper.rb
json_test_data-0.9.0 lib/json_test_data/data_structures/helpers/number_helper.rb
json_test_data-0.8.0 lib/json_test_data/data_structures/helpers/number_helper.rb
json_test_data-0.7.0 lib/json_test_data/data_structures/helpers/number_helper.rb
json_test_data-0.6.0 lib/json_test_data/data_structures/helpers/number_helper.rb