class Codebreaker::StatsStorage

Constants

PATH

Public Instance Methods

add(stat) click to toggle source
# File lib/codebreaker/stats_storage.rb, line 9
def add(stat)
  stats = load
  stats << stat
  save(stats)
end
load() click to toggle source
# File lib/codebreaker/stats_storage.rb, line 5
def load
  File.file?(PATH) ? YAML.load_file(PATH) : []
end

Private Instance Methods

save(stats) click to toggle source
# File lib/codebreaker/stats_storage.rb, line 17
def save(stats)
  Pathname(PATH).dirname.mkpath
  File.write(PATH, stats.to_yaml)
end