Class: BFS::TempWriter
- Inherits:
-
Tempfile
- Object
- Tempfile
- BFS::TempWriter
- Defined in:
- lib/bfs/helpers.rb
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(name, opts = {}, &closer) ⇒ TempWriter
constructor
A new instance of TempWriter.
Constructor Details
#initialize(name, opts = {}, &closer) ⇒ TempWriter
Returns a new instance of TempWriter.
6 7 8 9 10 |
# File 'lib/bfs/helpers.rb', line 6 def initialize(name, opts={}, &closer) @closer = closer @tempfile = ::Tempfile.new(File.basename(name.to_s), opts) super @tempfile end |
Instance Method Details
#close ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/bfs/helpers.rb', line 12 def close return if closed? path = @tempfile.path @tempfile.close @closer&.call(path) @tempfile.unlink end |