Sha256: 37853ae1d63e268d64c7ec7a5e9267a52587b934d48483b5712fbb8cb42255dc

Contents?: true

Size: 480 Bytes

Versions: 2

Compression:

Stored size: 480 Bytes

Contents

# frozen_string_literal: true

module Attractor
  # makes suggestions for refactorings
  class Suggester
    attr_accessor :values

    def initialize(values = [])
      @values = values
    end

    def suggest(threshold = 95)
      products = @values.map(&:score)
      products.extend(DescriptiveStatistics)
      quantile = products.percentile(threshold.to_i)

      @values.select { |val| val.score > quantile }
        .sort_by { |val| val.score }.reverse
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
attractor-2.6.0 lib/attractor/suggester.rb
attractor-2.5.0 lib/attractor/suggester.rb