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.



241
242
243
244
# File 'lib/tempfile.rb', line 241

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

Instance Method Details

#call(*args) ⇒ Object



246
247
248
249
250
251
252
253
254
255
256
257
258
# File 'lib/tempfile.rb', line 246

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