Class: TmpDirectory

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = "tmp") ⇒ TmpDirectory

Returns a new instance of TmpDirectory.



7
8
9
10
11
12
13
14
15
16
# File 'lib/tmp_directory.rb', line 7

def initialize name="tmp"
  @path = ::File.join(Dir.tmpdir, "#{name}-#{Time.now.strftime("%Y%m%d%H%M%S")}-#{Random.rand}")
  
  FileUtils.mkdir_p @path
  
  #Add shutdown hook to remove tar tmp directory
  Kernel.at_exit do 
    cleanup
  end
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



5
6
7
# File 'lib/tmp_directory.rb', line 5

def path
  @path
end