File

class File

Parent:
Object

Public Class Methods

atomic_write(file_name, temp_dir = dirname(file_name)) { |temp_file| ... } Show source

Write to a file atomically. Useful for situations where you don't want other processes or threads to see half-written files.

File.atomic_write('important.file') do |file|
  file.write('hello')
end

This method needs to create a temporary file. By default it will create