Class: Chan::Tempfile::Remover

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

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(tmpfile) ⇒ Remover

Returns a new instance of Remover.



189
190
191
192
# File 'lib/xchan/tempfile.rb', line 189

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

Instance Method Details

#call(*args) ⇒ Object



194
195
196
197
198
199
200
201
202
203
204
205
206
# File 'lib/xchan/tempfile.rb', line 194

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