Sha256: 9bd62dc95879d2e152a1a14efc9936055a62664ab7834e50578b8d0ee998726a
Contents?: true
Size: 1.2 KB
Versions: 19
Compression:
Stored size: 1.2 KB
Contents
module Relaton module Index # # File storage module contains methods to read and write files # module FileStorage # # Return file creation time # # @param [String] file file path # # @return [Time, nil] file creation time or nil if file does not exist # def ctime(file) File.exist?(file) && File.ctime(file) end # # Read file # # @param [String] file file path # # @return [String, nil] file content or nil if file does not exist # def read(file) return unless File.exist?(file) File.read file, encoding: "UTF-8" end # # Write file # # @param [String] file file path # @param [String] data content to write # # @return [void] # def write(file, data) dir = File.dirname file FileUtils.mkdir_p dir File.write file, data, encoding: "UTF-8" end # # Remove file # # @param [String] file file path # # @return [void] # def remove(file) return unless File.exist? file File.delete file end extend self end end end
Version data entries
19 entries across 19 versions & 1 rubygems