lib/bridge/points/duplicate.rb in bridge-0.1.3 vs lib/bridge/points/duplicate.rb in bridge-0.1.4

- old
+ new

@@ -12,25 +12,25 @@ @scores[number..(-1 - number)] end def average_score(number_to_skip = 1) scores = skipped_scores(number_to_skip) - (scores.inject(0.0) { |result, score| result += score} / scores.size).round(-1) + ((scores.inject(0.0) { |result, score| result += score} / scores.size) + 5).div(10) * 10 end def maximum {}.tap do |result| @scores.each_with_index do |score, i| result[score] ||= @scores[(i + 1)..-1].inject(0) { |points, s| points += (score <=> s) + 1 } end end end - def maximum_in_percents(precision = 2) + def maximum_in_percents maximum.tap do |result| result.each do |score, points| - result[score] = (points * 100.0 / theoretical_maximum).round(precision) + result[score] = (points * 100.0 / theoretical_maximum) end end end def butler(number_to_skip = 1) @@ -42,10 +42,10 @@ end def cavendish {}.tap do |result| @scores.each do |score| - result[score] ||= (@scores.inject(0.0) { |points, s| points += Bridge::Points.imps(score - s) } / (@scores.size - 1)).round(1) + result[score] ||= @scores.inject(0.0) { |points, s| points += Bridge::Points.imps(score - s) } / (@scores.size - 1) end end end end end