Module: Coinbot::UI::Command

Defined in:
lib/coinbot/ui/command.rb

Overview

This plugin is used to Refresh the Coinbot Status Section UI

Class Method Summary collapse

Class Method Details

.helpObject

Display Usage for this Module



194
195
196
197
198
199
200
# File 'lib/coinbot/ui/command.rb', line 194

public_class_method def self.help
  puts "USAGE:
   #{self}.refresh(
     command_status: 'required - Instatiated Coinbot::OrderBook::Probabilities Object'
   )
  "
end

.refresh(opts = {}) ⇒ Object

Supported Method Parameters

Coinbot::UI::Command.refresh(

action_command_status: 'required - Instatiated Coinbot::OrderBook::Probabilities Object'

)



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# File 'lib/coinbot/ui/command.rb', line 13

public_class_method def self.refresh(opts = {})
  command_win = opts[:command_win]
  key_press_event = opts[:key_press_event]

  key_press_event = Coinbot::UI.detect_key_press_in_ui(
    key_press_event: key_press_event,
    ui_win: command_win
  )

  if key_press_event.key_r
    key_r_color = :cyan
    key_r_style = :reverse
  else
    key_r_color = :white
    key_r_style = :bold
  end

  if key_press_event.key_u
    key_u_color = :cyan
    key_u_style = :reverse
  else
    key_u_color = :white
    key_u_style = :bold
  end

  if key_press_event.key_w
    key_w_color = :cyan
    key_w_style = :reverse
  else
    key_w_color = :white
    key_w_style = :bold
  end

  if key_press_event.key_x
    key_x_color = :cyan
    key_x_style = :reverse
  else
    key_x_color = :white
    key_x_style = :bold
  end

  out_line_no = 0
  Coinbot::UI.line(
    ui_win: command_win,
    out_line_no: out_line_no
  )

  out_line_no += 1
  command_win.setpos(out_line_no, Coinbot::UI.col_first)
  command_win.clrtoeol

  Coinbot::UI.colorize(
    ui_win: command_win,
    color: :yellow,
    style: :bold,
    string: "* v#{Coinbot::VERSION} >>> "
  )

  Coinbot::UI.colorize(
    ui_win: command_win,
    color: key_r_color,
    style: key_r_style,
    string: '['
  )

  Coinbot::UI.colorize(
    ui_win: command_win,
    color: :yellow,
    style: key_r_style,
    string: 'r'
  )

  Coinbot::UI.colorize(
    ui_win: command_win,
    color: key_r_color,
    style: key_r_style,
    string: ']eload bot conf'
  )

  Coinbot::UI.colorize(
    ui_win: command_win,
    color: :white,
    string: ' | '
  )

  Coinbot::UI.colorize(
    ui_win: command_win,
    color: key_u_color,
    style: key_u_style,
    string: '['
  )

  Coinbot::UI.colorize(
    ui_win: command_win,
    color: :yellow,
    style: key_u_style,
    string: 'u'
  )

  Coinbot::UI.colorize(
    ui_win: command_win,
    color: key_u_color,
    style: key_u_style,
    string: ']pdate summary'
  )

  Coinbot::UI.colorize(
    ui_win: command_win,
    color: :white,
    string: ' | '
  )

  Coinbot::UI.colorize(
    ui_win: command_win,
    color: key_w_color,
    style: key_w_style,
    string: '['
  )

  Coinbot::UI.colorize(
    ui_win: command_win,
    color: :yellow,
    style: key_w_style,
    string: 'w'
  )

  Coinbot::UI.colorize(
    ui_win: command_win,
    color: key_w_color,
    style: key_w_style,
    string: ']rite order book to disk'
  )

  Coinbot::UI.colorize(
    ui_win: command_win,
    color: :white,
    string: ' | '
  )

  Coinbot::UI.colorize(
    ui_win: command_win,
    color: key_x_color,
    style: key_x_style,
    string: 'e['
  )

  Coinbot::UI.colorize(
    ui_win: command_win,
    color: :yellow,
    style: key_x_style,
    string: 'x'
  )

  Coinbot::UI.colorize(
    ui_win: command_win,
    color: key_x_color,
    style: key_x_style,
    string: ']it'
  )

  out_line_no += 1
  Coinbot::UI.line(
    ui_win: command_win,
    out_line_no: out_line_no
  )

  command_win.refresh

  sleep 0.15 if key_press_event.key_r ||
                key_press_event.key_u ||
                key_press_event.key_w ||
                key_press_event.key_x
rescue Interrupt
  # Exit Gracefully if CTRL+C is Pressed During Session
  Coinbot.exit_gracefully(which_self: self)
rescue StandardError => e
  raise e
end