Sha256: 26472521c5b824673ea73a62160bda0547ed65f742c78acf266fc8d0d7b0a714

Contents?: true

Size: 826 Bytes

Versions: 2

Compression:

Stored size: 826 Bytes

Contents

# frozen_string_literal: true

module Cryptum
  module UI
    # This Class is Used to Detect Key Press Events
    module Exit
      public_class_method def self.gracefully(opts = {})
        event_history = opts[:event_history]

        Curses.close_screen

        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
        constants.sort
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cryptum-0.0.388 lib/cryptum/ui/exit.rb
cryptum-0.0.387 lib/cryptum/ui/exit.rb