Class: Downloads::Commands::Base

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

Direct Known Subclasses

Add, Attachments, Config, Help, Ls, Mv, Quit, Rm, Shell, Status, Sync, Video

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(configuration, argv) ⇒ Base

Returns a new instance of Base.



40
41
42
43
44
45
# File 'lib/downloads/commands.rb', line 40

def initialize(configuration, argv)
  @configuration = configuration
  @local         = configuration.local_server
  @remote        = configuration.remote_server
  configure(argv)
end

Instance Attribute Details

#configurationObject (readonly)

Returns the value of attribute configuration.



38
39
40
# File 'lib/downloads/commands.rb', line 38

def configuration
  @configuration
end

#localObject (readonly)

Returns the value of attribute local.



38
39
40
# File 'lib/downloads/commands.rb', line 38

def local
  @local
end

#optionsObject (readonly)

Returns the value of attribute options.



38
39
40
# File 'lib/downloads/commands.rb', line 38

def options
  @options
end

#remoteObject (readonly)

Returns the value of attribute remote.



38
39
40
# File 'lib/downloads/commands.rb', line 38

def remote
  @remote
end

Class Method Details

.command_nameObject



26
27
28
# File 'lib/downloads/commands.rb', line 26

def self.command_name
  name.split('::').last.downcase
end

.inherited(command) ⇒ Object



34
35
36
# File 'lib/downloads/commands.rb', line 34

def self.inherited(command)
  Commands.registry[command.command_name] = command
end

.usageObject



30
31
32
# File 'lib/downloads/commands.rb', line 30

def self.usage
  command_name
end

Instance Method Details

#configure(argv) ⇒ Object



47
48
# File 'lib/downloads/commands.rb', line 47

def configure(argv)
end

#runObject

Raises:

  • (NotImplementedError)


54
55
56
# File 'lib/downloads/commands.rb', line 54

def run
  raise NotImplementedError
end

#usageObject



50
51
52
# File 'lib/downloads/commands.rb', line 50

def usage
  self.class.usage
end

#valid?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/downloads/commands.rb', line 58

def valid?
  true
end