Class: Tempfile::Remover

Inherits:
Object
  • Object
show all
Defined in:
lib/tempfile.rb

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Remover


270
271
272
273
# File 'lib/tempfile.rb', line 270

def initialize(data)
  @pid = $$
  @data = data
end

Instance Method Details

#call(*args) ⇒ Object


275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
# File 'lib/tempfile.rb', line 275

def call(*args)
  return if @pid != $$

  path, tmpfile = *@data

  STDERR.print "removing ", path, "..." if $DEBUG

  tmpfile.close if tmpfile

  if path
    begin
      File.unlink(path)
    rescue Errno::ENOENT
    end
  end

  STDERR.print "done\n" if $DEBUG
end