Class: Codebreaker::Stats
- Inherits:
-
Object
- Object
- Codebreaker::Stats
- Defined in:
- lib/entities/stats.rb
Constant Summary collapse
- STORE =
'db/stats.yml'.freeze
Class Method Summary collapse
Class Method Details
.load ⇒ Object
24 25 26 |
# File 'lib/entities/stats.rb', line 24 def load File.exist?(STORE) ? YAML.load_file(STORE) : [] end |
.write(player) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/entities/stats.rb', line 7 def write(player) data = load data.push(player) sorted = data.sort if sorted.length >= 1 (0..(sorted.length - 1)).each do |i| sorted[i]. = i + 1 end else sorted[0]. = 1 end File.write(STORE, sorted.to_yaml) end |