Class: ListCommand

Inherits:
Command show all
Defined in:
lib/replicant/command.rb

Instance Attribute Summary

Attributes inherited from Command

#args

Instance Method Summary collapse

Methods inherited from Command

all, #execute, inherited, #initialize, load, #name, #usage

Constructor Details

This class inherits a constructor from Command

Instance Method Details

#descriptionObject



260
261
262
# File 'lib/replicant/command.rb', line 260

def description
  "print a list of available commands"
end

#runObject



264
265
266
267
268
269
270
271
# File 'lib/replicant/command.rb', line 264

def run
  command_list = Command.all.sort_by {|c| c.name}.map do |command|
    padding = 20 - command.name.length
    desc = "#{command.name} #{' ' * padding} -- #{command.description}"
    desc
  end
  output command_list.join("\n")
end

#valid_args?Boolean

Returns:

  • (Boolean)


256
257
258
# File 'lib/replicant/command.rb', line 256

def valid_args?
  args.blank?
end