Sha256: bcacfbfef0adedf9c091a4c32d99ce2d7607028b42739bbe5418aee694d0269c

Contents?: true

Size: 495 Bytes

Versions: 1

Compression:

Stored size: 495 Bytes

Contents

require 'yaml'
module Codebreaker
  module Data
    def save
      File.open("#{File.dirname(__FILE__)}/data.yaml", 'a') do |file|
        file.write({ player: @player, hints_left: @hints_left, \
                      attempts: @attempts, score: score }.to_yaml)
      end
    end

    def load
      file = File.open("#{File.dirname(__FILE__)}/data.yaml")
      games = []
      file.nil? ? "No #{file} file found." : YAML.load_stream(file) { |doc| games << doc }
      games
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
codebreaker_web-0.1.1 lib/codebreaker/data.rb