Class: RosettAi::Ui::AccessibleTui
- Defined in:
- lib/rosett_ai/ui/accessible_tui.rb
Overview
Accessible TUI adapter for screen-reader-friendly output.
Produces linear, sequential text without box-drawing characters or ANSI escape sequences. Auto-selected when assistive technology is detected (ORCA_RUNNING, BRLTTY_TTY).
Constant Summary
Constants inherited from Base
Instance Method Summary collapse
- #announce(message, priority: :polite) ⇒ Object
- #display_table(headers, rows) ⇒ Object
- #render(content) ⇒ Object
- #show_spinner(message) ⇒ Object
Methods inherited from Tui
Methods inherited from Base
#accessible?, #prompt_user, #text_direction
Constructor Details
This class inherits a constructor from RosettAi::Ui::Tui
Instance Method Details
#announce(message, priority: :polite) ⇒ Object
40 41 42 43 |
# File 'lib/rosett_ai/ui/accessible_tui.rb', line 40 def announce(, priority: :polite) prefix = priority == :assertive ? '[ASSERTIVE]' : '[POLITE]' warn("#{prefix} #{}") end |
#display_table(headers, rows) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rosett_ai/ui/accessible_tui.rb', line 19 def display_table(headers, rows) widths = compute_column_widths(headers, rows) header_line = format_row(headers, widths) separator = widths.map { |w| '-' * w }.join(' ') $stdout.puts(header_line) $stdout.puts(separator) rows.each { |row| $stdout.puts(format_row(row, widths)) } end |
#render(content) ⇒ Object
15 16 17 |
# File 'lib/rosett_ai/ui/accessible_tui.rb', line 15 def render(content) $stdout.puts(RosettAi::TextSanitizer.strip_ansi(String(content))) end |
#show_spinner(message) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/rosett_ai/ui/accessible_tui.rb', line 30 def show_spinner() $stdout.puts("Processing: #{}...") result = yield $stdout.puts('Done.') result rescue StandardError => e $stdout.puts('Failed.') raise e end |