Class: Zgomot::UI::ErrorWindow
- Includes:
- Utils
- Defined in:
- lib/zgomot/ui/windows.rb
Instance Attribute Summary collapse
-
#top ⇒ Object
readonly
Returns the value of attribute top.
Instance Method Summary collapse
- #display ⇒ Object
-
#initialize(top) ⇒ ErrorWindow
constructor
A new instance of ErrorWindow.
Methods included from Utils
Constructor Details
#initialize(top) ⇒ ErrorWindow
Returns a new instance of ErrorWindow.
305 306 307 308 |
# File 'lib/zgomot/ui/windows.rb', line 305 def initialize(top) @top = top display end |
Instance Attribute Details
#top ⇒ Object (readonly)
Returns the value of attribute top.
304 305 306 |
# File 'lib/zgomot/ui/windows.rb', line 304 def top @top end |
Instance Method Details
#display ⇒ Object
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 |
# File 'lib/zgomot/ui/windows.rb', line 309 def display = Zgomot.last_error text, text_color = if .nil? [["it's cool"], COLOR_BORDER] else [.scan(/.{1,#{WIDTH-4}}/), COLOR_ERROR] end set_color(COLOR_BORDER) { write(top, 0, '-' * WIDTH) write(top + 1, 0, '|') write(top + 1, WIDTH-1, '|') write(top + 2, 0, '|') write(top + 2, WIDTH-1, '|') write(top + 3, 0, '-' * WIDTH) } set_color(text_color) { lines = text.length > 1 ? 2 : 1 lines.times{|i| write(top + 1 + i, 2, "%-#{WIDTH-4}s" % text[i])} blank_width = WIDTH - 4 (2 - lines).times{|i| write(top + 2 - i, 2, ' ' * blank_width)} } end |