Sha256: 95089c66562d412bdfbc53f6f59c1e5a218764e7c5d37f4de46455575ea7f777
Contents?: true
Size: 659 Bytes
Versions: 3
Compression:
Stored size: 659 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::File::Path.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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
iostreams-0.20.2 | lib/io_streams/file/writer.rb |
iostreams-0.20.1 | lib/io_streams/file/writer.rb |
iostreams-0.20.0 | lib/io_streams/file/writer.rb |