Class: NProgress

Inherits:
Object
  • Object
show all
Defined in:
lib/ncurses_ui.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scr, row, col, color, bar_color, subbar_color, width = 0, value = 0, subvalue = 0, text = "") ⇒ NProgress

Returns a new instance of NProgress.



342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
# File 'lib/ncurses_ui.rb', line 342

def initialize scr, row, col, color, bar_color, subbar_color, width=0, value = 0, subvalue = 0, text = ""
  @width = width
  @color = color
  @bar_color = bar_color
  @subbar_color = subbar_color
  @row = row
  @col = col
  @winfg = Curses::Window.new 1, 1, @row, @col
  @winsfg = Curses::Window.new 1, 1, @row, @col
  @winbg = Curses::Window.new 1, self.width, @row, @col
  @value = value
  @subvalue = subvalue
  @text = text
  refresh
end

Instance Attribute Details

#subvalueObject

Returns the value of attribute subvalue.



340
341
342
# File 'lib/ncurses_ui.rb', line 340

def subvalue
  @subvalue
end

#textObject

Returns the value of attribute text.



341
342
343
# File 'lib/ncurses_ui.rb', line 341

def text
  @text
end

#valueObject

Returns the value of attribute value.



340
341
342
# File 'lib/ncurses_ui.rb', line 340

def value
  @value
end

Instance Method Details

#closeObject



386
387
388
389
390
# File 'lib/ncurses_ui.rb', line 386

def close
  @winbg.close
  @winsfg.close
  @winfg.close
end

#refreshObject



372
373
374
375
376
377
378
379
380
381
# File 'lib/ncurses_ui.rb', line 372

def refresh
  bgOffset = [fgw, sfgw].max
  sbOffset = fgw
  Nutils.print @winbg, 0, bgOffset, @text[bgOffset..-1], @color
  Nutils.print @winsfg, 0, sbOffset, @text[sbOffset..-1], @subbar_color if sfgw > 0
  Nutils.print @winfg, 0, 0, @text, @bar_color if fgw > 0
  @winbg.refresh
  @winsfg.refresh if sfgw > 0
  @winfg.refresh if fgw > 0
end

#resizeObject



383
384
# File 'lib/ncurses_ui.rb', line 383

def resize
end

#widthObject



358
359
360
# File 'lib/ncurses_ui.rb', line 358

def width
  [@col + @width, Curses.cols].min - @col
end