module Codebreaker

Constants

NoAttamptsError
STAT_FILE
VERSION

Public Class Methods

create(**diffucult) click to toggle source
# File lib/codebreaker.rb, line 9
def create(**diffucult)
  BLL::GameEngine.new(**diffucult)
end
fetch_statistic(path) click to toggle source
# File lib/codebreaker.rb, line 25
def fetch_statistic(path)
  create_db path

  YAML.load_file path
end
save_statistic(path, **statistic_info) click to toggle source
# File lib/codebreaker.rb, line 13
def save_statistic(path, **statistic_info)
  [].tap do |data_to_write|
    data_to_write << statistic_info

    create_db path

    data_to_write.concat YAML.load_file(path) if YAML.load_file(path)

    File.open(path, 'w') { |file| file.write(data_to_write.to_yaml) }
  end
end

Private Class Methods

create_db(path) click to toggle source
# File lib/codebreaker.rb, line 33
def create_db path
  File.new path,"w" unless File.exist? path
end