Sha256: ad8db95d56613316c8ad16018aeb74ba13b8046462ef4f1ab656edd22e155b2b
Contents?: true
Size: 716 Bytes
Versions: 2
Compression:
Stored size: 716 Bytes
Contents
class DataBaseManager @instance = new private_class_method :new class << self attr_reader :instance end def save_game_results(attributes) data = { name: attributes[0], difficulty: attributes[1], attempts_total: attributes[2], attempts_used: attributes[3], hints_total: attributes[4], hints_used: attributes[4] } Dir.mkdir('lib/db') unless Dir.exist?('lib/db') File.open('lib/db/codebreaker_db.yml', 'a') { |file| file.puts(data.to_yaml) } end def load_game_results game_results = [] File.open('lib/db/codebreaker_db.yml') do |yaml_file| YAML.load_stream(yaml_file) do |document| game_results << document end end game_results end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
codebreaker_vv-0.2.0 | lib/src/data_base_manager.rb |
codebreaker_vv-0.1.0 | lib/src/data_base_manager.rb |