Class: Attractor::Suggester
- Inherits:
-
Object
- Object
- Attractor::Suggester
- Defined in:
- lib/attractor/suggester.rb
Overview
makes suggestions for refactorings
Instance Attribute Summary collapse
-
#values ⇒ Object
Returns the value of attribute values.
Instance Method Summary collapse
-
#initialize(values = []) ⇒ Suggester
constructor
A new instance of Suggester.
- #suggest(threshold = 95) ⇒ Object
Constructor Details
#initialize(values = []) ⇒ Suggester
Returns a new instance of Suggester.
8 9 10 |
# File 'lib/attractor/suggester.rb', line 8 def initialize(values = []) @values = values end |
Instance Attribute Details
#values ⇒ Object
Returns the value of attribute values.
6 7 8 |
# File 'lib/attractor/suggester.rb', line 6 def values @values end |
Instance Method Details
#suggest(threshold = 95) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/attractor/suggester.rb', line 12 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 |