Class: Sbire::CommandManager

Inherits:
Object
  • Object
show all
Defined in:
lib/sbire/command_manager.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ CommandManager

Returns a new instance of CommandManager.



5
6
7
# File 'lib/sbire/command_manager.rb', line 5

def initialize(path)
  @commands = YAML.load_file(path) if File.exist?(path)
end

Instance Attribute Details

#commandsObject

Returns the value of attribute commands.



3
4
5
# File 'lib/sbire/command_manager.rb', line 3

def commands
  @commands
end

Instance Method Details

#execute(hypotheses, index) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/sbire/command_manager.rb', line 9

def execute(hypotheses, index)
  current_hypothese = hypotheses[index]
  unless current_hypothese.first.empty?
    command = find(current_hypothese)
    system("#{command} &")
    return command
  end
end