Sha256: db82bb444efce509374446abdf90506cc00cce4bcb5d1f316a9e2f99b1a49a80

Contents?: true

Size: 481 Bytes

Versions: 3

Compression:

Stored size: 481 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

3 entries across 3 versions & 1 rubygems

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