class Codebreaker::Entities::Statistics
Public Instance Methods
stats(list)
click to toggle source
# File lib/codebreaker/entities/statistics.rb, line 6 def stats(list) difficulties = list.group_by { |score| score[:difficulty] } %i[hell medium easy].reduce([]) do |sorted_difficulties, difficulty_name| if difficulties[difficulty_name] sorted_difficulties + stats_sort(difficulties[difficulty_name]) else sorted_difficulties end end end
Private Instance Methods
stats_sort(scores)
click to toggle source
# File lib/codebreaker/entities/statistics.rb, line 19 def stats_sort(scores) scores.sort_by! { |score| [score[:attempts_used], score[:hints_used]] }.reverse end