class Dhalang::FileUtils
Contains common logic for files.
Public Class Methods
create_temp_file(extension, content = nil)
click to toggle source
Creates a new temp file.
@param [String] extension The extension of the file. @param [String] content The content of the file. (Optional)
@return [Tempfile] The created temp file.
# File lib/Dhalang/file_utils.rb, line 20 def self.create_temp_file(extension, content = nil) temp_file = Tempfile.new(["dhalang",".#{extension}"]) unless(content == nil) temp_file.write(content) temp_file.rewind end temp_file end
delete(file)
click to toggle source
Deletes the given file.
@param [File] file The file to delete.
# File lib/Dhalang/file_utils.rb, line 32 def self.delete(file) file.close unless file.closed? file.unlink end
read_binary(file_path)
click to toggle source
Reads the file under the given filepath as a binary.
@param [String] file_path The absolute path of the file to read.
@return [String] The binary content under the file_path.
# File lib/Dhalang/file_utils.rb, line 10 def self.read_binary(file_path) IO.binread(file_path) end