Class: Jura::RootControl

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/jura/root_control.rb

Direct Known Subclasses

Control::Sprint

Instance Method Summary collapse

Instance Method Details

#commandsObject



28
29
30
# File 'lib/jura/root_control.rb', line 28

def commands
  @commands ||= {}
end

#config_commandsObject



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_commandsObject



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

Returns:

  • (Boolean)


19
20
21
# File 'lib/jura/root_control.rb', line 19

def support_command?(name)
  commands.keys.include?(name)
end

#undo_commandObject



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