Class: RosettAi::Ui::Base
- Inherits:
-
Object
- Object
- RosettAi::Ui::Base
- Defined in:
- lib/rosett_ai/ui/base.rb
Overview
Abstract interface for UI implementations.
All UI adapters (TUI, GTK4, Qt6) must inherit from this class and implement the required methods. The shared example 'a UI implementation' verifies conformance.
Constant Summary collapse
- RTL_LOCALES =
['ar', 'he', 'fa', 'ur'].freeze
Instance Method Summary collapse
- #accessible? ⇒ Boolean
- #announce(message) ⇒ Object
- #display_table(headers, rows) ⇒ Object
- #prompt_user(question, choices: nil) ⇒ Object
- #render(content) ⇒ Object
- #show_spinner(message) ⇒ Object
- #text_direction(locale = nil) ⇒ Object
Instance Method Details
#accessible? ⇒ Boolean
36 37 38 |
# File 'lib/rosett_ai/ui/base.rb', line 36 def accessible? ENV.key?('ORCA_RUNNING') || ENV.key?('BRLTTY_TTY') end |
#announce(message) ⇒ Object
32 33 34 |
# File 'lib/rosett_ai/ui/base.rb', line 32 def announce() raise NotImplementedError, "#{self.class}#announce not implemented" end |
#display_table(headers, rows) ⇒ Object
20 21 22 |
# File 'lib/rosett_ai/ui/base.rb', line 20 def display_table(headers, rows) raise NotImplementedError, "#{self.class}#display_table not implemented" end |
#prompt_user(question, choices: nil) ⇒ Object
24 25 26 |
# File 'lib/rosett_ai/ui/base.rb', line 24 def prompt_user(question, choices: nil) raise NotImplementedError, "#{self.class}#prompt_user not implemented" end |
#render(content) ⇒ Object
16 17 18 |
# File 'lib/rosett_ai/ui/base.rb', line 16 def render(content) raise NotImplementedError, "#{self.class}#render not implemented" end |
#show_spinner(message) ⇒ Object
28 29 30 |
# File 'lib/rosett_ai/ui/base.rb', line 28 def show_spinner(, &) raise NotImplementedError, "#{self.class}#show_spinner not implemented" end |
#text_direction(locale = nil) ⇒ Object
40 41 42 43 |
# File 'lib/rosett_ai/ui/base.rb', line 40 def text_direction(locale = nil) lang = locale || ENV.fetch('LANG', 'en')[0, 2] RTL_LOCALES.include?(lang) ? :rtl : :ltr end |