Sha256: fceaa5670ec393e4f7c8f4ee1c9f9b34be8fef416a2a3aad335c2409334fe060
Contents?: true
Size: 609 Bytes
Versions: 55
Compression:
Stored size: 609 Bytes
Contents
# require "eitil_core/files/create_file" Kernel.module_eval do def create_file(file_name, data, directory: nil, suffix: nil, file_type: nil, append: false) directory = directory || "#{Dir.home}/data" suffix = suffix || DateTime.now.prettify file_type = file_type || "json" if file_type == "json" data = JSON.pretty_generate(data) end path = "#{directory}/#{file_name}_#{suffix}.#{file_type}" if append and Dir[path].present? File.open(path, "a+") { |f| f << data } return path end File.write(path, data) return path end end
Version data entries
55 entries across 55 versions & 1 rubygems