Class: BFS::TempWriter
- Inherits:
-
Object
- Object
- BFS::TempWriter
- Defined in:
- lib/bfs/helpers.rb
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(name, &closer) ⇒ TempWriter
constructor
A new instance of TempWriter.
- #path ⇒ Object
- #write(data) ⇒ Object
Constructor Details
#initialize(name, &closer) ⇒ TempWriter
Returns a new instance of TempWriter.
5 6 7 8 |
# File 'lib/bfs/helpers.rb', line 5 def initialize(name, &closer) @closer = closer @tempfile = ::Tempfile.new(File.basename(name.to_s)) end |
Instance Method Details
#close ⇒ Object
18 19 20 21 22 23 |
# File 'lib/bfs/helpers.rb', line 18 def close path = @tempfile.path @tempfile.close @closer.call(path) if @closer @tempfile.unlink end |
#path ⇒ Object
10 11 12 |
# File 'lib/bfs/helpers.rb', line 10 def path @tempfile.path end |
#write(data) ⇒ Object
14 15 16 |
# File 'lib/bfs/helpers.rb', line 14 def write(data) @tempfile.write(data) end |