Class: Downloads::Commands::Mv

Inherits:
Base
  • Object
show all
Defined in:
lib/downloads/commands/mv.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#configuration, #local, #options, #remote

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

command_name, inherited, #initialize, #usage

Constructor Details

This class inherits a constructor from Downloads::Commands::Base

Instance Attribute Details

#sourceObject

Returns the value of attribute source.



4
5
6
# File 'lib/downloads/commands/mv.rb', line 4

def source
  @source
end

#targetObject

Returns the value of attribute target.



4
5
6
# File 'lib/downloads/commands/mv.rb', line 4

def target
  @target
end

Class Method Details

.usageObject



6
7
8
# File 'lib/downloads/commands/mv.rb', line 6

def self.usage
  "#{super} SOURCE TARGET"
end

Instance Method Details

#configure(argv) ⇒ Object



10
11
12
13
# File 'lib/downloads/commands/mv.rb', line 10

def configure(argv)
  self.source = shift_argument(argv)
  self.target = shift_argument(argv)
end

#runObject



15
16
17
18
# File 'lib/downloads/commands/mv.rb', line 15

def run
  remote.run("mv '#{source}' '#{target}'")
  local.run("mv '#{source}' '#{target}'") if local.exists?(source)
end

#valid?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/downloads/commands/mv.rb', line 20

def valid?
  source && target
end