Class: Shellout::CommandLoop

Inherits:
Object
  • Object
show all
Defined in:
lib/shellout/command_loop.rb

Instance Method Summary collapse

Constructor Details

#initialize(menu) ⇒ CommandLoop

Returns a new instance of CommandLoop.



5
6
7
# File 'lib/shellout/command_loop.rb', line 5

def initialize(menu)
  @menu = menu
end

Instance Method Details

#callObject



9
10
11
12
13
14
15
16
17
18
# File 'lib/shellout/command_loop.rb', line 9

def call
  loop do
    begin
      task = @menu.call
      task.call
    rescue Interrupt    # ^C
      puts              # Add a new line in case we are prompting
    end
  end
end