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

.mode_switch!(mode = nil) ⇒ Object

Parameters:

  • mode (Symbol) (defaults to: nil)


18
19
20
21
22
23
24
25
26
27
# File 'lib/vedeu/runtime/main_loop.rb', line 18

def mode_switch!(mode = nil)
  @loop        = false
  @mode_switch = true

  Vedeu::Terminal::Mode.switch_mode!(mode)

  Vedeu.trigger(:_drb_restart_)

  fail Vedeu::Error::ModeSwitch
end

.safe_exit_point!void

This method returns an undefined value.

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

Raises:



64
65
66
# File 'lib/vedeu/runtime/main_loop.rb', line 64

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

.start!void

This method returns an undefined value.

Start the main loop.

Yield Returns:

  • (void)

    The client application.



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/vedeu/runtime/main_loop.rb', line 33

def start!
  @started     = true
  @loop        = true
  @mode_switch = false

  Vedeu.trigger(:_refresh_cursor_, Vedeu.focus)

  Vedeu.trigger(:_refresh_)

  while @loop
    yield

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

.stop!void

This method returns an undefined value.

Signal that we wish to terminate the running application.



54
55
56
# File 'lib/vedeu/runtime/main_loop.rb', line 54

def stop!
  @loop = false
end