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.
462 463 464 465 |
# File 'lib/tui.rb', line 462 def initialize(screen) @screen = screen @lines = [] end |
Instance Attribute Details
#lines ⇒ Object (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
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 |
#clear ⇒ Object
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 |