Sha256: 899ec741fec72cce15c5dab0776ddb66c53af2433e076428620c7db2f04bd3ee
Contents?: true
Size: 702 Bytes
Versions: 8
Compression:
Stored size: 702 Bytes
Contents
# frozen_string_literal: true module Basketball module App # Knows how to read and write documents to disk. class FileStore class PathNotFoundError < StandardError; end def exist?(path) File.exist?(path) end def read(path) raise PathNotFoundError, "'#{path}' not found" unless exist?(path) File.read(path) end def write(path, contents) dir = File.dirname(path) FileUtils.mkdir_p(dir) File.write(path, contents) nil end def delete(path) raise PathNotFoundError, "'#{path}' not found" unless exist?(path) File.delete(path) nil end end end end
Version data entries
8 entries across 8 versions & 1 rubygems