class R2do::Command

Attributes

description[R]

@return [String] the description for the command.

extended[R]

@return [String] the name of this command.

short[R]

@return [String] the value for the command switch.

Public Class Methods

new(short, extended, description) click to toggle source

Creates an instance of a Command

@param [String] short the short option name for this command @param [String] extended the full option name for this command @param [String] argument the optional argument for commands that have arguments @param [String] description the command’s description

# File lib/r2do/commands/command.rb, line 33
def initialize(short, extended, description)
  if short.nil? or extended.nil? or description.nil?
    raise ArgumentError
  end

  @short = short
  @extended = extended
  @description = description
end

Public Instance Methods

execute(args) click to toggle source

Executes the callback of this command

@param [Array] args the collection of arguments @return [void]

# File lib/r2do/commands/command.rb, line 47
def execute(args)
  raise ScriptError, "Cannot call execute on an abstract command"
end
help() click to toggle source
# File lib/r2do/commands/command.rb, line 51
def help()
  return "No help available for this command."
end
to_s() click to toggle source

Returns a string representation of this Command

@return [String] the representation of this Command

# File lib/r2do/commands/command.rb, line 58
def to_s()
  return "%2s, %-10s \t# %s" % [@short, @extended, @description]
end