Sha256: 374c1983ecda49cd982bee32f897d278cfbadb3849da3eef165469d568971ed5
Contents?: true
Size: 647 Bytes
Versions: 2
Compression:
Stored size: 647 Bytes
Contents
module IOStreams module File class Writer # Write to a named file # # Note: # If an exception is raised whilst the file is being written to the file is removed to # prevent incomplete / partial files from being created. def self.open(file_name, **args, &block) raise(ArgumentError, 'File name must be a string') unless file_name.is_a?(String) IOStreams.mkpath(file_name) begin ::File.open(file_name, 'wb', &block) rescue StandardError => e File.unlink(file_name) if File.exist?(file_name) raise(e) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
iostreams-0.19.0 | lib/io_streams/file/writer.rb |
iostreams-0.18.0 | lib/io_streams/file/writer.rb |