Module: Cryptum::Event::OrderBook

Defined in:
lib/cryptum/event/order_book.rb

Overview

This Module is used to Write the Order Book from Memory to File When the “w” Key is Pressed

Class Method Summary collapse

Class Method Details

.helpObject

Display Usage for this Module



28
29
30
31
32
# File 'lib/cryptum/event/order_book.rb', line 28

public_class_method def self.help
  puts "USAGE:
    #{self}.write()
  "
end

.write(opts = {}) ⇒ Object

Supported Method Parameters

Cryptum::Event::OrderBook.write( )



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/cryptum/event/order_book.rb', line 12

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

  terminal_win.key_press_event.key_w = false unless terminal_win.nil?
  order_book_file = event_history.order_book[:path]

  File.write(
    order_book_file,
    JSON.pretty_generate(event_history.order_book)
  )
rescue Interrupt, StandardError => e
  Cryptum::Log.append(level: :error, msg: e, which_self: self, event_history: event_history)
end