Module: Cryptum::UI::Exit

Defined in:
lib/cryptum/ui/exit.rb

Overview

Gracefully Exit the UI and Attempt to Save event_history to Order Book Session File.

Class Method Summary collapse

Class Method Details

.gracefully(opts = {}) ⇒ Object

Supported Method Parameters

Cryptum::UI::Exit.gracefully(

event_history: 'optional - Pass in the event_history if available to save to order book'

)



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/cryptum/ui/exit.rb', line 13

public_class_method def self.gracefully(opts = {})
  event_history = opts[:event_history]

  Curses.close_screen
  msg = 'Session Gracefully Terminated.'
  Cryptum::Log.append(level: :info, msg: msg, which_self: self, event_history: event_history)

  exit 0
rescue Interrupt, StandardError => e
  # Produce a Stacktrace for anything else
  Cryptum::Log.append(level: :fatal, msg: e, which_self: self, event_history: event_history)
  exit 1
ensure
  Cryptum::Event::OrderBook.write(event_history: event_history) if event_history
end

.helpObject

Display a List of Every UI Module



31
32
33
# File 'lib/cryptum/ui/exit.rb', line 31

public_class_method def self.help
  puts constants.sort
end