Sha256: 7d46486dd0c80cd17c671f4e2ab46958ce543bcb2345b65b2a638ffb4c676f32
Contents?: true
Size: 547 Bytes
Versions: 3
Compression:
Stored size: 547 Bytes
Contents
# frozen_string_literal: true module CodebreakerKirill class Stats def self.save_game(user) @data = File.exist?('stats.yml') ? YAML.load_file('stats.yml') : [] @data << user File.new('stats.yml', 'w') unless File.exist?('stats.yml') File.open('stats.yml', 'w') { |file| file.write(@data.to_yaml) } end def self.show_stats @data = File.exist?('stats.yml') ? YAML.load_file('stats.yml') : [] @data.sort_by! { |user| [user.level[:attempts], user.attempts_used, user.hints_used] } end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
codebreaker_kirill-2.0.0 | lib/codebreaker_kirill/stats.rb |
codebreaker_kirill-1.3.7 | lib/codebreaker_kirill/stats.rb |
codebreaker_kirill-1.3.6 | lib/codebreaker_kirill/stats.rb |