Class: Tempfile::Remover

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

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Remover

Returns a new instance of Remover.


264
265
266
267
# File 'lib/tempfile.rb', line 264

def initialize(data)
  @pid = $$
  @data = data
end

Instance Method Details

#call(*args) ⇒ Object


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

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

  path, tmpfile = @data

  STDERR.print "removing ", path, "..." if $DEBUG

  tmpfile.close if tmpfile

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

  STDERR.print "done\n" if $DEBUG
end