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

- old
+ new

@@ -15,9 +15,13 @@ def load_file 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 + private def create_storage FileUtils.mkdir_p(FILE_DIRECTORY) File.open(storage_path, "w") unless File.exist?(storage_path)