Method: Dropbox::API#rename
- Defined in:
- lib/dropbox/api.rb
#rename(path, new_name, options = {}) ⇒ Object
Renames a file. Takes the same options and raises the same exceptions as the move method.
Calling
session.rename 'path/to/file', 'new_name'
is equivalent to calling
session.move 'path/to/file', 'path/to/new_name'
343 344 345 346 347 348 349 350 |
# File 'lib/dropbox/api.rb', line 343 def rename(path, new_name, ={}) raise ArgumentError, "Names cannot have slashes in them" if new_name.include?('/') path = path.sub(/\/$/, '') destination = path.split('/') destination[destination.size - 1] = new_name destination = destination.join('/') move path, destination, end |