Class: R2do::Command
- Inherits:
-
Object
- Object
- R2do::Command
- Defined in:
- lib/r2do/commands/command.rb
Direct Known Subclasses
R2do::Commands::CategoryCommand, R2do::Commands::DisplayCategoriesCommand, R2do::Commands::HelpCommand, R2do::Commands::InitCommand, R2do::Commands::NowCommand, R2do::Commands::Option, R2do::Commands::TaskCommand, Option
Instance Attribute Summary collapse
-
#description ⇒ String
readonly
The description for the command.
-
#extended ⇒ String
readonly
The name of this command.
-
#short ⇒ String
readonly
The value for the command switch.
Instance Method Summary collapse
-
#execute(args) ⇒ void
Executes the callback of this command.
- #help ⇒ Object
-
#initialize(short, extended, description) ⇒ Command
constructor
Creates an instance of a Command.
-
#to_s ⇒ String
Returns a string representation of this Command.
Constructor Details
#initialize(short, extended, description) ⇒ Command
Creates an instance of a Command
33 34 35 36 37 38 39 40 41 |
# 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 |
Instance Attribute Details
#description ⇒ String (readonly)
Returns the description for the command.
25 26 27 |
# File 'lib/r2do/commands/command.rb', line 25 def description @description end |
#extended ⇒ String (readonly)
Returns the name of this command.
23 24 25 |
# File 'lib/r2do/commands/command.rb', line 23 def extended @extended end |
#short ⇒ String (readonly)
Returns the value for the command switch.
21 22 23 |
# File 'lib/r2do/commands/command.rb', line 21 def short @short end |
Instance Method Details
#execute(args) ⇒ void
This method returns an undefined value.
Executes the callback of this command
47 48 49 |
# File 'lib/r2do/commands/command.rb', line 47 def execute(args) raise ScriptError, "Cannot call execute on an abstract command" end |
#help ⇒ Object
51 52 53 |
# File 'lib/r2do/commands/command.rb', line 51 def help() return "No help available for this command." end |
#to_s ⇒ String
Returns a string representation of this Command
58 59 60 |
# File 'lib/r2do/commands/command.rb', line 58 def to_s() return "%2s, %-10s \t# %s" % [@short, @extended, @description] end |