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.



566
567
568
569
570
571
572
573
574
575
576
577
578
# File 'lib/ncurses_ui.rb', line 566

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.



565
566
567
# File 'lib/ncurses_ui.rb', line 565

def count
  @count
end

#titleObject

Returns the value of attribute title.



565
566
567
# File 'lib/ncurses_ui.rb', line 565

def title
  @title
end

#visibleObject

Returns the value of attribute visible.



565
566
567
# File 'lib/ncurses_ui.rb', line 565

def visible
  @visible
end

Instance Method Details

#closeObject



608
609
610
# File 'lib/ncurses_ui.rb', line 608

def close
  @win.close
end

#heightObject



589
590
591
592
593
594
595
596
# File 'lib/ncurses_ui.rb', line 589

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

#refreshObject



602
603
604
605
606
# File 'lib/ncurses_ui.rb', line 602

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

#resizeObject



598
599
600
# File 'lib/ncurses_ui.rb', line 598

def resize
  @win.resize height, width
end

#widthObject



580
581
582
583
584
585
586
587
# File 'lib/ncurses_ui.rb', line 580

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