Module: UtilsIO
- Defined in:
- lib/mrpin/core/utils/utils_io.rb
Class Method Summary collapse
- .to_path_absolute(path_relative) ⇒ Object
- .to_path_relative(path_absolute) ⇒ Object
- .try_remove_file_relative(path_relative) ⇒ Object
Class Method Details
.to_path_absolute(path_relative) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# 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) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# 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) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# 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 |