Class: TempDir
- Inherits:
-
Object
- Object
- TempDir
- Defined in:
- lib/inochi/util/tempdir.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(basename = nil, dirname = nil) ⇒ TempDir
constructor
A new instance of TempDir.
Constructor Details
#initialize(basename = nil, dirname = nil) ⇒ TempDir
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/inochi/util/tempdir.rb', line 12 def initialize basename = nil, dirname = nil args = [basename || File.basename($0), dirname].compact file = Tempfile.new(*args) @path = file.path # replace the file with a directory file.close! FileUtils.mkdir_p @path # clean up on exit at_exit { close } end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
10 11 12 |
# File 'lib/inochi/util/tempdir.rb', line 10 def path @path end |
Instance Method Details
#close ⇒ Object
26 27 28 |
# File 'lib/inochi/util/tempdir.rb', line 26 def close FileUtils.rm_rf @path end |