Class: Vedeu::Application

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeApplication



14
# File 'lib/vedeu/application.rb', line 14

def initialize; end

Class Method Details

.restartObject

Returns [].

Returns:



9
10
11
# File 'lib/vedeu/application.rb', line 9

def start
  new.start
end

.startObject

Returns [].

Returns:



6
7
8
# File 'lib/vedeu/application.rb', line 6

def start
  new.start
end

Instance Method Details

#main_sequenceObject (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns [].

Returns:



54
55
56
57
58
59
60
61
62
# File 'lib/vedeu/application.rb', line 54

def main_sequence
  if Configuration.interactive?
    Input.capture

  else
    # TODO: What should happen here?

  end
end

#run_manyObject (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns [].

Returns:



66
67
68
69
70
71
72
73
74
# File 'lib/vedeu/application.rb', line 66

def run_many
  loop { yield }

rescue ModeSwitch
  Terminal.switch_mode!

  Application.restart

end

#runnerObject (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns [].

Returns:



42
43
44
45
46
47
48
49
50
# File 'lib/vedeu/application.rb', line 42

def runner
  if Configuration.once?
    yield

  else
    run_many { yield }

  end
end

#startObject

Starts the application!

  • A new terminal screen is opened (or rather the current terminal is requested into either :raw or :cooked mode).

  • The cursor visibility is then set dependent on this mode. In :raw mode, the cursor is hidden.

  • The ‘:initialize` event is triggered. Vedeu does not handle this event; the client application may treat this event as Vedeu signalling that it is now ready.

  • We enter into the main sequence where the application will either run once or continuous, interactively or standalone.

Returns:



28
29
30
31
32
33
34
35
36
# File 'lib/vedeu/application.rb', line 28

def start
  Terminal.open do
    Terminal.set_cursor_mode

    Vedeu.events.trigger(:_initialize_)

    runner { main_sequence }
  end
end