lib/codebreaker/file_store.rb in codebreaker-mikhail-0.1.5 vs lib/codebreaker/file_store.rb in codebreaker-mikhail-0.2.0

- old
+ new

@@ -1,9 +1,9 @@ # frozen_string_literal: true module Codebreaker - module FileStore + module FileStore FILE_DIRECTORY = "statistics" FILE_NAME = "statistics.yml" def save_file(game) validate_state(game.state, :win) @@ -16,9 +16,13 @@ create_storage unless storage_exists? (YAML.load_file(storage_path) || {})[:codebrakers] || [] end def statistics + load_file.each.sort_by { |game| [game[:attempts], game[:used_hints], game[:used_attempts]] } + end + + def self.statistics load_file.each.sort_by { |game| [game[:attempts], game[:used_hints], game[:used_attempts]] } end private