Class: MoveCommand
Overview
Move files ###################################
Instance Attribute Summary
Attributes inherited from Command
Instance Method Summary collapse
- #directory ⇒ Object
- #dry_run ⇒ Object
- #filename ⇒ Object
-
#initialize(*args) ⇒ MoveCommand
constructor
A new instance of MoveCommand.
- #priority ⇒ Object
- #real_run ⇒ Object
Methods inherited from Command
Constructor Details
#initialize(*args) ⇒ MoveCommand
Returns a new instance of MoveCommand.
38 39 40 |
# File 'lib/commands.rb', line 38 def initialize *args (@filename, @directory, @path)=args end |
Instance Method Details
#directory ⇒ Object
43 |
# File 'lib/commands.rb', line 43 def directory ; transform @directory ; end |
#dry_run ⇒ Object
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/commands.rb', line 45 def dry_run case $OPTS[:on_collision] when 'overwrite' "mv #{filename} #{directory}" when 'rename' "mv #{filename} #{File.join(directory,unique_name)}" else # 'ignore' also # emit nothing end end |
#filename ⇒ Object
42 |
# File 'lib/commands.rb', line 42 def filename ; transform @filename ; end |
#priority ⇒ Object
36 |
# File 'lib/commands.rb', line 36 def priority ; 2 ; end |
#real_run ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/commands.rb', line 56 def real_run case $OPTS[:on_collision] when 'overwrite' mv when 'rename' if collision? FileUtils.mv filename, File.join(directory,unique_name) else mv end else # captures the 'ignore' option too # do nothing end end |