Sha256: b9df0829610debf0402f227ee9ff7d6e0431bfe9189610fd3cb6662c5914904e

Contents?: true

Size: 323 Bytes

Versions: 1

Compression:

Stored size: 323 Bytes

Contents

# frozen_string_literal: true

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
codebreaker_rg_game-1.7 lib/codebreaker/utils/yaml_mapper.rb