Class: Tui::Section
- Inherits:
-
Object
- Object
- Tui::Section
- Defined in:
- lib/tui.rb
Instance Attribute Summary collapse
-
#lines ⇒ Object
readonly
Returns the value of attribute lines.
Instance Method Summary collapse
- #add_line(background: nil, truncate: true) {|line| ... } ⇒ Object
- #clear ⇒ Object
- #divider(char: '─') ⇒ Object
-
#initialize(screen) ⇒ Section
constructor
A new instance of Section.
Constructor Details
#initialize(screen) ⇒ Section
Returns a new instance of Section.
478 479 480 481 |
# File 'lib/tui.rb', line 478 def initialize(screen) @screen = screen @lines = [] end |
Instance Attribute Details
#lines ⇒ Object (readonly)
Returns the value of attribute lines.
476 477 478 |
# File 'lib/tui.rb', line 476 def lines @lines end |
Instance Method Details
#add_line(background: nil, truncate: true) {|line| ... } ⇒ Object
483 484 485 486 487 488 |
# File 'lib/tui.rb', line 483 def add_line(background: nil, truncate: true) line = Line.new(@screen, background: background, truncate: truncate) @lines << line yield line if block_given? line end |
#clear ⇒ Object
497 498 499 |
# File 'lib/tui.rb', line 497 def clear @lines.clear end |
#divider(char: '─') ⇒ Object
490 491 492 493 494 495 |
# File 'lib/tui.rb', line 490 def divider(char: '─') add_line do |line| span = [@screen.width - 1, 1].max line.write << char * span end end |