Class: Tempfile::Remover

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

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Remover

Returns a new instance of Remover.



308
309
310
311
# File 'lib/tempfile.rb', line 308

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

Instance Method Details

#call(*args) ⇒ Object



313
314
315
316
317
318
319
320
321
322
323
324
# File 'lib/tempfile.rb', line 313

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

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

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

  $stderr.puts "done" if $DEBUG
end