Sha256: d04c18ae07788e3b5c09b5fbf0270bcb3228745cf5111f92d3d3e91c4c69f596

Contents?: true

Size: 1.15 KB

Versions: 35

Compression:

Stored size: 1.15 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 = '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

      # Display a List of Every UI Module

      public_class_method def self.help
        puts constants.sort
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
cryptum-0.0.466 lib/cryptum/ui/exit.rb
cryptum-0.0.465 lib/cryptum/ui/exit.rb
cryptum-0.0.464 lib/cryptum/ui/exit.rb
cryptum-0.0.463 lib/cryptum/ui/exit.rb
cryptum-0.0.462 lib/cryptum/ui/exit.rb
cryptum-0.0.461 lib/cryptum/ui/exit.rb
cryptum-0.0.460 lib/cryptum/ui/exit.rb
cryptum-0.0.459 lib/cryptum/ui/exit.rb
cryptum-0.0.458 lib/cryptum/ui/exit.rb
cryptum-0.0.457 lib/cryptum/ui/exit.rb
cryptum-0.0.456 lib/cryptum/ui/exit.rb
cryptum-0.0.455 lib/cryptum/ui/exit.rb
cryptum-0.0.454 lib/cryptum/ui/exit.rb
cryptum-0.0.453 lib/cryptum/ui/exit.rb
cryptum-0.0.452 lib/cryptum/ui/exit.rb
cryptum-0.0.451 lib/cryptum/ui/exit.rb
cryptum-0.0.450 lib/cryptum/ui/exit.rb
cryptum-0.0.449 lib/cryptum/ui/exit.rb
cryptum-0.0.448 lib/cryptum/ui/exit.rb
cryptum-0.0.447 lib/cryptum/ui/exit.rb