Class: Tui::Section

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(screen) ⇒ Section

Returns a new instance of Section.



462
463
464
465
# File 'lib/tui.rb', line 462

def initialize(screen)
  @screen = screen
  @lines = []
end

Instance Attribute Details

#linesObject (readonly)

Returns the value of attribute lines.



460
461
462
# File 'lib/tui.rb', line 460

def lines
  @lines
end

Instance Method Details

#add_line(background: nil, truncate: true) {|line| ... } ⇒ Object

Yields:

  • (line)


467
468
469
470
471
472
# File 'lib/tui.rb', line 467

def add_line(background: nil, truncate: true)
  line = Line.new(@screen, background: background, truncate: truncate)
  @lines << line
  yield line if block_given?
  line
end

#clearObject



481
482
483
# File 'lib/tui.rb', line 481

def clear
  @lines.clear
end

#divider(char: '─') ⇒ Object



474
475
476
477
478
479
# File 'lib/tui.rb', line 474

def divider(char: '─')
  add_line do |line|
    span = [@screen.width - 1, 1].max
    line.write << char * span
  end
end