Class: EhbrsRubyUtils::WebUtils::Videos::File::Rename

Inherits:
Object
  • Object
show all
Defined in:
lib/ehbrs_ruby_utils/web_utils/videos/file/rename.rb

Instance Method Summary collapse

Instance Method Details

#can_rename?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/ehbrs_ruby_utils/web_utils/videos/file/rename.rb', line 14

def can_rename?
  ::File.exist?(original_path) && !::File.exist?(target_path)
end

#performObject



18
19
20
21
22
23
# File 'lib/ehbrs_ruby_utils/web_utils/videos/file/rename.rb', line 18

def perform
  return unless can_rename?

  ::FileUtils.mkdir_p(::File.dirname(target_path))
  ::FileUtils.mv(original_path, target_path)
end