Sha256: a16f36450c734a68677fe3a057173fa0bda4f0a4bfa667f8a2e30ee6fb84d065

Contents?: true

Size: 621 Bytes

Versions: 1

Compression:

Stored size: 621 Bytes

Contents

class DataBaseManager
  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[5] }
    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

1 entries across 1 versions & 1 rubygems

Version Path
codebreaker_vv-1.0.0 lib/src/data_base_manager.rb