Class: Balboa::CLI::Application
- Inherits:
-
Object
- Object
- Balboa::CLI::Application
- Defined in:
- lib/balboa/cli/application.rb
Constant Summary collapse
- CommandNotFound =
Class.new(RuntimeError)
Instance Method Summary collapse
- #add_command(key, command) ⇒ Object
- #execute ⇒ Object
-
#initialize(command_id) ⇒ Application
constructor
A new instance of Application.
Constructor Details
#initialize(command_id) ⇒ Application
Returns a new instance of Application.
8 9 10 11 |
# File 'lib/balboa/cli/application.rb', line 8 def initialize(command_id) @command_id = command_id.to_s @commands = Hash.new { fail CommandNotFound } end |
Instance Method Details
#add_command(key, command) ⇒ Object
13 14 15 |
# File 'lib/balboa/cli/application.rb', line 13 def add_command(key, command) @commands[key.to_s] = command end |
#execute ⇒ Object
17 18 19 |
# File 'lib/balboa/cli/application.rb', line 17 def execute @commands[@command_id].execute end |