Sha256: c9f9a8172630466b969f5b3a9690af9fc07f46ab4b9a9271ea16f0df84284ffc
Contents?: true
Size: 481 Bytes
Versions: 2
Compression:
Stored size: 481 Bytes
Contents
# frozen_string_literal: true module Codebreaker module Storage FILE_PATH = '/lib/data/data.yml' def save(data) create_storage unless storage_exist? File.open(FILE_PATH, 'w') { |file| file.write data.to_yaml } end def restore_storage storage_exist? ? YAML.load(File.open(FILE_PATH)) : [] end private def storage_exist? File.exist? FILE_PATH end def create_storage File.new(FILE_PATH, 'w+') end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
codebreaker_kolyanjy-0.1.6 | lib/modules/storage.rb |
codebreaker_kolyanjy-0.1.5 | lib/modules/storage.rb |