Class: Vedeu::Runtime::MainLoop

Inherits:
Object
  • Object
show all
Defined in:
lib/vedeu/runtime/main_loop.rb

Overview

Provides the main loop for a Vedeu application.

Class Method Summary collapse

Class Method Details

.safe_exit_point!void

This method returns an undefined value.

:nocov: Check the application has started and we wish to continue running.

Raises:



51
52
53
# File 'lib/vedeu/runtime/main_loop.rb', line 51

def safe_exit_point!
  fail Vedeu::Error::Interrupt if @started && !@loop
end

.start!void

This method returns an undefined value.

:nocov: Start the main loop.

Yield Returns:

  • (void)

    The client application.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/vedeu/runtime/main_loop.rb', line 20

def start!
  @started = true
  @loop    = true

  while @loop
    yield

    Vedeu::Terminal::Buffer.render

    safe_exit_point!
  end
rescue Vedeu::Error::Interrupt
  Vedeu.log(type:    :info,
            message: 'Vedeu execution interrupted, exiting.')
end

.stop!void

This method returns an undefined value.

Signal that we wish to terminate the running application.



40
41
42
# File 'lib/vedeu/runtime/main_loop.rb', line 40

def stop!
  @loop = false
end