Class: Tmptation::TmpFile
- Inherits:
-
Tempfile
- Object
- Tempfile
- Tmptation::TmpFile
- Includes:
- InstanceTracking, SafeDeletable
- Defined in:
- lib/tmptation.rb
Overview
Subclass of core lib’s Tempfile that allows safely deleting all of its instances. It also provides a convenient way to add content to the file.
Constant Summary
Constants included from SafeDeletable
Class Method Summary collapse
-
.delete_all ⇒ Object
(also: -@)
Safe deletes and closes all instances.
Instance Method Summary collapse
-
#initialize(name = 'anon', body = '') ⇒ TmpFile
constructor
A new instance of TmpFile.
-
#path ⇒ Object
File’s path as a Pathname.
Methods included from InstanceTracking
Methods included from SafeDeletable
path_for, safe?, #safe_delete, #safe_delete_contents
Constructor Details
#initialize(name = 'anon', body = '') ⇒ TmpFile
Returns a new instance of TmpFile.
148 149 150 151 152 |
# File 'lib/tmptation.rb', line 148 def initialize(name='anon', body='') super(name) self << body self.rewind end |
Class Method Details
.delete_all ⇒ Object Also known as: -@
Safe deletes and closes all instances
132 133 134 135 136 137 138 |
# File 'lib/tmptation.rb', line 132 def delete_all instances.each do |instance| instance.safe_delete instance.close end instances.clear end |
Instance Method Details
#path ⇒ Object
File’s path as a Pathname
158 159 160 |
# File 'lib/tmptation.rb', line 158 def path Pathname(super) end |