Class: Codebreaker::Stats
- Inherits:
-
Object
- Object
- Codebreaker::Stats
- Defined in:
- lib/codebraker_ov/entities/stats.rb
Constant Summary collapse
- STORE =
'db/stats.yml'.freeze
Class Method Summary collapse
Class Method Details
.load ⇒ Object
21 22 23 |
# File 'lib/codebraker_ov/entities/stats.rb', line 21 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 |
# File 'lib/codebraker_ov/entities/stats.rb', line 7 def write(player) data = load data.push(player) sorted = data.sort data.map!.with_index do |record, index| record. = index + 1 record end File.write(STORE, sorted.to_yaml) end |