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, width = 0, value = 0, text = "") ⇒ NProgress

Returns a new instance of NProgress.



269
270
271
272
273
274
275
276
277
278
279
280
# File 'lib/ncurses_ui.rb', line 269

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

Instance Attribute Details

#textObject

Returns the value of attribute text.



268
269
270
# File 'lib/ncurses_ui.rb', line 268

def text
  @text
end

#valueObject

Returns the value of attribute value.



267
268
269
# File 'lib/ncurses_ui.rb', line 267

def value
  @value
end

Instance Method Details

#closeObject



302
303
304
305
# File 'lib/ncurses_ui.rb', line 302

def close
  @winbg.close
  @winfg.close
end

#refreshObject



291
292
293
294
295
296
297
# File 'lib/ncurses_ui.rb', line 291

def refresh
  offset = fgw
  Nutils.print @winbg, 0, offset, @text[offset..-1], @color
  Nutils.print @winfg, 0, 0, @text, @bar_color if fgw > 0
  @winbg.refresh
  @winfg.refresh if fgw > 0
end

#resizeObject



299
300
# File 'lib/ncurses_ui.rb', line 299

def resize
end

#widthObject



282
283
284
# File 'lib/ncurses_ui.rb', line 282

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