Sha256: 06cbb9ef5b6ee07a2f68428e19c43a957382b247192e60338b7d3b7da68ddd26

Contents?: true

Size: 396 Bytes

Versions: 2

Compression:

Stored size: 396 Bytes

Contents

# frozen_string_literal: true

module Codebreaker
  class YamlMapper
    PATH = 'database/codebreaker_db.yml'
    class << self
      def save(object)
        stats = load
        stats << object
        File.open(PATH, 'w') do |file|
          file.write(stats.to_yaml)
        end
      end

      def load
        File.file?(PATH) ? YAML.load(File.read(PATH)) : []
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
codebreaker_rg_game-1.1 lib/codebreaker/utils/yaml_mapper.rb
codebreaker_rg_game-1.0 lib/codebreaker/utils/yaml_mapper.rb