class TN::TempFile
Public Class Methods
new(content: nil, file: nil, name: 'tanga') { |self| ... }
click to toggle source
# File lib/tn/temp_file.rb, line 3 def initialize(content: nil, file: nil, name: 'tanga') extension = File.extname(name) file_name = SecureRandom.hex @file = file || ::Tempfile.new([file_name, extension]) @file.binmode if content @file.write(content) if content @file.close end if block_given? yield(self) done end end
Public Instance Methods
done()
click to toggle source
# File lib/tn/temp_file.rb, line 27 def done @file.close @file.unlink end
method_missing(method, *args, &block)
click to toggle source
# File lib/tn/temp_file.rb, line 19 def method_missing(method, *args, &block) @file.send(method, *args, &block) end
path()
click to toggle source
# File lib/tn/temp_file.rb, line 23 def path File.absolute_path(@file.path) end