Class: Downloads::Commands::Config

Inherits:
Base
  • Object
show all
Defined in:
lib/downloads/commands/config.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, #valid?

Constructor Details

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

Instance Attribute Details

#keyObject

Returns the value of attribute key.



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

def key
  @key
end

#valueObject

Returns the value of attribute value.



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

def value
  @value
end

Class Method Details

.usageObject



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

def self.usage
  "#{super} [KEY [VALUE]]"
end

Instance Method Details

#configure(argv) ⇒ Object



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

def configure(argv)
  self.key   = shift_argument(argv)
  self.value = shift_argument(argv)
end

#runObject



15
16
17
18
19
20
21
22
23
# File 'lib/downloads/commands/config.rb', line 15

def run
  if value
    configuration[key] = value
  elsif key
    puts configuration[key]
  else
    puts configuration.to_yaml
  end
end