Class: Codebreaker::StatsStorage

Inherits:
Object
  • Object
show all
Defined in:
lib/codebreaker/stats_storage.rb

Constant Summary collapse

PATH =
'./db/data.yml'.freeze

Instance Method Summary collapse

Instance Method Details

#add(stat) ⇒ Object



9
10
11
12
13
# File 'lib/codebreaker/stats_storage.rb', line 9

def add(stat)
  stats = load
  stats << stat
  save(stats)
end

#loadObject



5
6
7
# File 'lib/codebreaker/stats_storage.rb', line 5

def load
  File.file?(PATH) ? YAML.load_file(PATH) : []
end