Class: TmpDirectory
- Inherits:
-
Object
- Object
- TmpDirectory
- Defined in:
- lib/tmp_directory.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(name = "tmp") ⇒ TmpDirectory
constructor
A new instance of TmpDirectory.
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
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/tmp_directory.rb', line 5 def path @path end |