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.



187
188
189
190
# File 'lib/xchan/tempfile.rb', line 187

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

Instance Method Details

#call(*args) ⇒ Object



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

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

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

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

  warn "done" if $DEBUG
end