Class: Tui::Layout

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

Overview

Main window layout.

It represents the main window of the application's TUI

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Layout

Internal content is expected to be rendered each time => should be callable

Examples:

Tui::Layout.new { Block.column "foo", "bar" }


10
11
12
# File 'lib/tui/layout.rb', line 10

def initialize &block
  @root = block || -> { Tui::Block::column "Hello TUI!" }
end

Instance Method Details

#render ⇒ Object

Render content to produce a frame, which could be print -ed.



15
16
17
18
19
20
# File 'lib/tui/layout.rb', line 15

def render
  box = @root.call
  raise "main window is not a block but #{box.class}" unless box.is_a? Tui::Block

  box
end