class PlayersRating attr_accessor :stats def initialize stats_loader end private def stats_loader return @stats = false unless File.exist?(Files::STATS_FILE) load_stats sort_players_rating end def load_stats File.open(Files::STATS_FILE) do |file| @stats = Array.new(Psych.load_stream(file)) end end def sort_players_rating @stats.sort_by! { |value| [-value.difficulty_level, value.attempts_used, value.hints_used] } end end