Class: Tempfile::Remover

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

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(tmpfile) ⇒ Remover

Returns a new instance of Remover.



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

def initialize(tmpfile)
  @pid = Process.pid
  @tmpfile = tmpfile
end

Instance Method Details

#call(*args) ⇒ Object



274
275
276
277
278
279
280
281
282
283
284
285
286
# File 'lib/tempfile.rb', line 274

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

  $stderr.puts "removing #{@tmpfile.path}..." if $DEBUG

  @tmpfile.close
  begin
    File.unlink(@tmpfile.path)
  rescue Errno::ENOENT
  end

  $stderr.puts "done" if $DEBUG
end