Sha256: 149b6ccfe78a46bdcedb3e9e56371cf28f762c5bdeeefdec374f76cdf1c7f187
Contents?: true
Size: 1.44 KB
Versions: 24
Compression:
Stored size: 1.44 KB
Contents
# frozen_string_literal: true module Cryptum # Cryptum::UI Module used for Presenting the # Cryptum Curses Interface module UI # Gracefully Exit the UI and Attempt to Save event_history to Order Book Session File. module Exit # Supported Method Parameters:: # Cryptum::UI::Exit.gracefully( # event_history: 'optional - Pass in the event_history if available to save to order book' # ) public_class_method def self.gracefully(opts = {}) event_history = opts[:event_history] Curses.close_screen msg = '' if event_history.respond_to?('order_book') msg = "session: #{event_history.order_book[:path].split('/').first}, " msg += "symbol: #{event_history.order_book[:symbol]}" end msg += ' => Session Gracefully Terminated.' Cryptum::Log.append(level: :info, msg: msg, which_self: self) exit 0 rescue Interrupt, StandardError => e # Produce a Stacktrace for anything else Cryptum::Log.append(level: :fatal, msg: e, which_self: self) exit 1 ensure if event_history order_book_file = event_history.order_book[:path] File.write( order_book_file, JSON.pretty_generate(event_history.order_book) ) end end # Display a List of Every UI Module public_class_method def self.help puts constants.sort end end end end
Version data entries
24 entries across 24 versions & 1 rubygems