Class: NDownloadBox

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, w, h) ⇒ NDownloadBox

Returns a new instance of NDownloadBox.



473
474
475
476
477
478
479
480
481
482
483
484
485
# File 'lib/ncurses_ui.rb', line 473

def initialize scr, row, col, color, w, h
  @scr = scr
  @row = row
  @col = col
  @color = color
  @width = w
  @height = h
  @win = Curses::Window.new height, width, @row, @col
  @visible = false
  @count = 0
  @title = ""
  refresh
end

Instance Attribute Details

#countObject

Returns the value of attribute count.



472
473
474
# File 'lib/ncurses_ui.rb', line 472

def count
  @count
end

#titleObject

Returns the value of attribute title.



472
473
474
# File 'lib/ncurses_ui.rb', line 472

def title
  @title
end

#visibleObject

Returns the value of attribute visible.



472
473
474
# File 'lib/ncurses_ui.rb', line 472

def visible
  @visible
end

Instance Method Details

#closeObject



515
516
517
# File 'lib/ncurses_ui.rb', line 515

def close
  @win.close
end

#heightObject



496
497
498
499
500
501
502
503
# File 'lib/ncurses_ui.rb', line 496

def height
  h = [@row + @height, Curses.lines].min - @row
  if h == 0
    Curses.lines - @row
  else
    h
  end
end

#refreshObject



509
510
511
512
513
# File 'lib/ncurses_ui.rb', line 509

def refresh
  return unless @visible
  Nutils.print @win, 0, 0, "Downloading #{@count} track#{@count > 1?"s":""} | #{title}", :default
  @win.refresh
end

#resizeObject



505
506
507
# File 'lib/ncurses_ui.rb', line 505

def resize
  @win.resize height, width
end

#widthObject



487
488
489
490
491
492
493
494
# File 'lib/ncurses_ui.rb', line 487

def width
  w = [@col + @width, Curses.cols].min - @col
  if w == 0
    Curses.cols - @col
  else
    w
  end
end