class Codebreaker::Storage

Constants

PATH

Public Class Methods

file_path(filename) click to toggle source
# File lib/codebreaker/storage.rb, line 11
def file_path(filename)
  "#{PATH}#{filename}.yml"
end
load_file(filename) click to toggle source
# File lib/codebreaker/storage.rb, line 7
def load_file(filename)
  YAML.load_file(file_path(filename)) if File.exist?(file_path(filename))
end
save_score(data) click to toggle source
# File lib/codebreaker/storage.rb, line 15
def save_score(data)
  current_file_path = file_path(:statistics)
  File.new(current_file_path, 'w+') unless File.exist?(current_file_path)
  record = load_file('statistics') || []
  File.write(current_file_path, (record << data).to_yaml)
end