# frozen_string_literal: true module Codebreaker class Statistics class << self def save(stats) YamlMapper.save(stats) end def output stats = load sort(stats) hash_stats = {} stats.each_index do |index| hash_stats[index] = stats[index].to_s end hash_stats.to_a end private def sort(array_stats) array_stats.sort_by! { |stats| [stats[:attempts_used], stats[:hints_used]] }.reverse end def load YamlMapper.load end end end end