class Codebreaker::Entities::Storage

Constants

FILE_NAME

Public Instance Methods

create() click to toggle source
# File lib/codebreaker/entities/storage.rb, line 6
def create
  File.new(FILE_NAME, 'w')
  File.write(FILE_NAME, [].to_yaml)
end
load() click to toggle source
# File lib/codebreaker/entities/storage.rb, line 11
def load
  YAML.load(File.open(FILE_NAME), [Menu]) if file_exists?
end
save(object) click to toggle source
# File lib/codebreaker/entities/storage.rb, line 15
def save(object)
  File.open(FILE_NAME, 'w') { |file| file.write(YAML.dump(object)) }
end
save_game_results(object) click to toggle source
# File lib/codebreaker/entities/storage.rb, line 19
def save_game_results(object)
  create unless file_exists?
  save(load.push(object))
end

Private Instance Methods

file_exists?() click to toggle source
# File lib/codebreaker/entities/storage.rb, line 26
def file_exists?
  File.exist?(FILE_NAME)
end