Class: Jura::RootControl
- Inherits:
-
Object
- Object
- Jura::RootControl
- Includes:
- Singleton
- Defined in:
- lib/jura/root_control.rb
Direct Known Subclasses
Instance Method Summary collapse
- #commands ⇒ Object
- #config_commands ⇒ Object
- #execute_command(name, opts = {}) ⇒ Object
- #executed_commands ⇒ Object
- #set_command(key, command) ⇒ Object
- #support_command?(name) ⇒ Boolean
- #undo_command ⇒ Object
Instance Method Details
#commands ⇒ Object
28 29 30 |
# File 'lib/jura/root_control.rb', line 28 def commands @commands ||= {} end |
#config_commands ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/jura/root_control.rb', line 32 def config_commands set_command("board", Command::Board) set_command("issue", Command::Issue) set_command("sprint", Command::Sprint) set_command("help", Command::Help) set_command("exit", Command::Exit) end |
#execute_command(name, opts = {}) ⇒ Object
23 24 25 26 |
# File 'lib/jura/root_control.rb', line 23 def execute_command(name, opts = {}) commands[name].execute!(opts[:sub_cmd], opts[:args]) executed_commands << [commands[name], opts] end |
#executed_commands ⇒ Object
40 41 42 |
# File 'lib/jura/root_control.rb', line 40 def executed_commands @executed_commands ||= [] end |
#set_command(key, command) ⇒ Object
8 9 10 |
# File 'lib/jura/root_control.rb', line 8 def set_command(key, command) commands[key] = command end |
#support_command?(name) ⇒ Boolean
19 20 21 |
# File 'lib/jura/root_control.rb', line 19 def support_command?(name) commands.keys.include?(name) end |
#undo_command ⇒ Object
12 13 14 15 16 17 |
# File 'lib/jura/root_control.rb', line 12 def undo_command return if executed_commands.length.zero? command, opts = executed_commands.pop command.execute!(opts[:sub_cmd], opts[:args]) end |