module UtilsIO

Public Class Methods

to_path_absolute(path_relative) click to toggle source
# File lib/mrpin/core/utils/utils_io.rb, line 19
def self.to_path_absolute(path_relative)
  if path_relative.nil?
    puts 'UtilsIO::to_path_absolute arg is nil'
    return ''
  end

  root_dir = Constants.get_dir_assets

  File.join(root_dir, path_relative)
end
to_path_relative(path_absolute) click to toggle source
# File lib/mrpin/core/utils/utils_io.rb, line 3
def self.to_path_relative(path_absolute)
  if path_absolute.nil?
    puts 'UtilsIO::to_path_relative arg is nil'
    return ''
  end

  root_dir = Constants.get_dir_assets

  result = path_absolute.dup

  result.slice!(root_dir)

  result
end
try_remove_file_relative(path_relative) click to toggle source
# File lib/mrpin/core/utils/utils_io.rb, line 31
def self.try_remove_file_relative(path_relative)
  return if path_relative.blank?

  path_absolute = UtilsIO.to_path_absolute(path_relative)

  if File.exist?(path_absolute)
    File.delete(path_absolute)
  end

  nil
end