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.



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

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

Instance Attribute Details

#linesObject (readonly)

Returns the value of attribute lines.



473
474
475
# File 'lib/tui.rb', line 473

def lines
  @lines
end

Instance Method Details

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

Yields:

  • (line)


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

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



494
495
496
# File 'lib/tui.rb', line 494

def clear
  @lines.clear
end

#divider(char: '─') ⇒ Object



487
488
489
490
491
492
# File 'lib/tui.rb', line 487

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