class Statistics
Public Instance Methods
stats(list)
click to toggle source
# File lib/app/entities/statistics.rb, line 4 def stats(list) difficulties = list.group_by { |score| score[:difficulty] } %w[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/app/entities/statistics.rb, line 17 def stats_sort(scores) scores.sort_by! { |score| [score[:attempts_used], score[:hints_used]] }.reverse end