Module: Clacky::Utils::PathHelper

Defined in:
lib/clacky/utils/path_helper.rb

Class Method Summary collapse

Class Method Details

.safe_basename(path, placeholder: "?") ⇒ Object

Safely get basename from path, return placeholder if path is nil



7
8
9
10
11
12
# File 'lib/clacky/utils/path_helper.rb', line 7

def self.safe_basename(path, placeholder: "?")
  return placeholder if path.nil? || path.to_s.empty?
  File.basename(path.to_s)
rescue StandardError
  placeholder
end