class Codebreaker::Stats

Constants

STORE

Public Class Methods

load() click to toggle source
# File lib/codebraker_ov/entities/stats.rb, line 21
def load
  File.exist?(STORE) ? YAML.load_file(STORE) : []
end
write(player) click to toggle source
# 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.rating = index + 1
    record
  end

  File.write(STORE, sorted.to_yaml)
end