Sha256: 3434306fcce952b52a28786ffafdbd1e913bf9f3e52200eed320c3b5365b7304

Contents?: true

Size: 374 Bytes

Versions: 4

Compression:

Stored size: 374 Bytes

Contents

# frozen_string_literal: true

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

      def load(path)
        File.file?(path) ? Psych.load(File.read(path)) : []
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
codebreaker_rg_game-1.11 lib/codebreaker/utils/yaml_mapper.rb
codebreaker_rg_game-1.10 lib/codebreaker/utils/yaml_mapper.rb
codebreaker_rg_game-1.9 lib/codebreaker/utils/yaml_mapper.rb
codebreaker_rg_game-1.8 lib/codebreaker/utils/yaml_mapper.rb