Class: Gts::Command
- Inherits:
-
Object
- Object
- Gts::Command
- Defined in:
- lib/gts/command.rb
Direct Known Subclasses
DumpCommand, DumpSizeCommand, HelpCommand, ListKnownDevicesCommand, StorageInfoCommand, UptimeCommand
Defined Under Namespace
Classes: CommandError, UnknownCommand
Constant Summary collapse
- @@known_commands =
{}
- @@known_commands_descriptions =
{}
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
Class Method Summary collapse
- .execute(command_str) ⇒ Object
- .known_commands_descriptions ⇒ Object
- .register(name, handler, desc = "") ⇒ Object
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
13 14 15 |
# File 'lib/gts/command.rb', line 13 def args @args end |
Class Method Details
.execute(command_str) ⇒ Object
20 21 22 23 24 |
# File 'lib/gts/command.rb', line 20 def self.execute(command_str) parser = Gts::CommandParser.new command_name, @args = *parser.parse(command_str) command_handler(command_name.to_sym).execute end |
.known_commands_descriptions ⇒ Object
26 27 28 |
# File 'lib/gts/command.rb', line 26 def self.known_commands_descriptions @@known_commands_descriptions end |
.register(name, handler, desc = "") ⇒ Object
15 16 17 18 |
# File 'lib/gts/command.rb', line 15 def self.register(name, handler, desc="") @@known_commands[name] = handler @@known_commands_descriptions[name] = desc end |