Sha256: 7fb1df77126ac6906cf07a485efae0e8f103dd9d9eedf685e98609f6c4715588
Contents?: true
Size: 567 Bytes
Versions: 4
Compression:
Stored size: 567 Bytes
Contents
# frozen_string_literal: true class Codebreaker::Storage PATH = 'lib/codebreaker/src/' class << self def load_file(filename) YAML.load_file(file_path(filename)) if File.exist?(file_path(filename)) end def file_path(filename) "#{PATH}#{filename}.yml" end 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 end end
Version data entries
4 entries across 4 versions & 1 rubygems