Sha256: 940edc8b07974757c196776958d329b104b8814816baaf4a3a609bb617157565
Contents?: true
Size: 732 Bytes
Versions: 4
Compression:
Stored size: 732 Bytes
Contents
# frozen_string_literal: true # Main Gem module module CodeBrkrGameTraining # Module for file operations module FileOperations def save_to_file(**args) ensuring_directory_availability args[:directory] yml = YAML.dump(args[:data]) File.open(File.join(args[:directory], args[:file]), 'a') { |yml_file| yml_file.write(yml) } end def load_from_file(directory, file) begin yml_data = File.open(File.join(directory, file), &:read) rescue Errno::ENOENT yml_data = '' end YAML.load_stream( yml_data ) end private def ensuring_directory_availability(directory) Dir.mkdir(directory) unless Dir.exist?(directory) end end end
Version data entries
4 entries across 4 versions & 1 rubygems