Sha256: ba63376f999292522ceb0eef80ff1a568a26673c1ffab544b1f5b0adbe08a293
Contents?: true
Size: 643 Bytes
Versions: 5
Compression:
Stored size: 643 Bytes
Contents
# frozen_string_literal: true module Trifle module Stats class Designator class Geometric attr_reader :min, :max def initialize(min:, max:) @min = min.negative? ? 0 : min @max = max end def designate(value:) # rubocop:disable Metrics/AbcSize return min.to_f.to_s if value <= min return "#{max.to_f}+" if value > max return (10**value.floor.to_s.length).to_f.to_s if value > 1 return 1.0.to_s if value > 0.1 # ugh? (1.0 / 10**value.to_s.gsub('0.', '').split(/[1-9]/).first.length).to_s end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems