Sha256: 68c303ed42dfe8fd88d91a490fb51e337271eb6f2cfc54d5cfc2f08f724bdb82
Contents?: true
Size: 595 Bytes
Versions: 5
Compression:
Stored size: 595 Bytes
Contents
require_relative '../constants' require_relative 'game' require 'yaml' module CodebreakerKarolina class DBYaml include CodebreakerConstants def save(game) File.open(FILE_NAME, 'a') do |filename| YAML.dump(game, filename) end end def statistic games = load_file_stats return if games.empty? games.sort_by do |game| [-DIFFICULTY_SORT[game.difficulty.name.to_sym], game.user.used_attempts, game.user.used_hints] end end private def load_file_stats YAML.load_stream(File.open(FILE_NAME)) end end end
Version data entries
5 entries across 5 versions & 1 rubygems