Class: ServerStatus::Commands::Add
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- ServerStatus::Commands::Add
- Defined in:
- lib/server-status/commands/add.rb
Instance Attribute Summary
Attributes inherited from BaseCommand
Instance Method Summary collapse
-
#initialize(config, host, name = nil) ⇒ Add
constructor
A new instance of Add.
- #perform ⇒ Object
Methods inherited from BaseCommand
Constructor Details
#initialize(config, host, name = nil) ⇒ Add
Returns a new instance of Add.
4 5 6 7 8 9 |
# File 'lib/server-status/commands/add.rb', line 4 def initialize(config, host, name=nil) super(config) @host = host @name = name || host end |
Instance Method Details
#perform ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/server-status/commands/add.rb', line 11 def perform settings['hosts'] ||= {} # Check to see if we're already tracking settings['hosts'].each do |name, host| if name == @name puts "#{name} already exists" exit(1) end end settings['hosts'][@name] = @host config.save puts "Added #{@name}" end |