Sha256: a96024008829ce1ee0b62c7d7d6c8953d9ebff9b2de02ec3ac7f09bec0170303

Contents?: true

Size: 456 Bytes

Versions: 5

Compression:

Stored size: 456 Bytes

Contents

# frozen_string_literal: true

module Trifle
  module Stats
    class Designator
      class Custom
        attr_reader :buckets

        def initialize(buckets:)
          @buckets = buckets.sort
        end

        def designate(value:)
          return buckets.first.to_s if value <= buckets.first
          return "#{buckets.last}+" if value > buckets.last

          (buckets.find { |b| value.ceil < b }).to_s
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
trifle-stats-1.3.1 lib/trifle/stats/designator/custom.rb
trifle-stats-1.3.0 lib/trifle/stats/designator/custom.rb
trifle-stats-1.2.0 lib/trifle/stats/designator/custom.rb
trifle-stats-1.1.2 lib/trifle/stats/designator/custom.rb
trifle-stats-1.1.1 lib/trifle/stats/designator/custom.rb