class File_manager
Public Instance Methods
create_file(path, extension)
click to toggle source
# File lib/Util/file_manager.rb, line 5 def create_file(path, extension) dir = File.dirname(path) unless File.directory?(dir) FileUtils.mkdir_p(dir) end path << ".#{extension}" File.new(path, 'w') end
get_file_name(file_path)
click to toggle source
# File lib/Util/file_manager.rb, line 26 def get_file_name(file_path) name_with_extension = /(?!.*\/)(.*)$/.match(file_path).to_s name = /.*(?=\.)/.match(name_with_extension).to_s end
read_file(path)
click to toggle source
# File lib/Util/file_manager.rb, line 16 def read_file(path) File.open(path, 'rb') { |file| file.read } end
write_on_file(text, path)
click to toggle source
# File lib/Util/file_manager.rb, line 20 def write_on_file(text, path) File.open(path, 'w') do |f| f.write text end end