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 =
Returns Rtl locales constant.
['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) ⇒ Symbol
Return the text direction for the current locale.
Instance Method Details
#accessible? ⇒ Boolean
37 38 39 |
# File 'lib/rosett_ai/ui/base.rb', line 37 def accessible? ENV.key?('ORCA_RUNNING') || ENV.key?('BRLTTY_TTY') end |
#announce(message) ⇒ Object
33 34 35 |
# File 'lib/rosett_ai/ui/base.rb', line 33 def announce() raise NotImplementedError, "#{self.class}#announce not implemented" end |
#display_table(headers, rows) ⇒ Object
21 22 23 |
# File 'lib/rosett_ai/ui/base.rb', line 21 def display_table(headers, rows) raise NotImplementedError, "#{self.class}#display_table not implemented" end |
#prompt_user(question, choices: nil) ⇒ Object
25 26 27 |
# File 'lib/rosett_ai/ui/base.rb', line 25 def prompt_user(question, choices: nil) raise NotImplementedError, "#{self.class}#prompt_user not implemented" end |
#render(content) ⇒ Object
17 18 19 |
# File 'lib/rosett_ai/ui/base.rb', line 17 def render(content) raise NotImplementedError, "#{self.class}#render not implemented" end |
#show_spinner(message) ⇒ Object
29 30 31 |
# File 'lib/rosett_ai/ui/base.rb', line 29 def show_spinner(, &) raise NotImplementedError, "#{self.class}#show_spinner not implemented" end |
#text_direction(locale = nil) ⇒ Symbol
Return the text direction for the current locale.
43 44 45 46 |
# File 'lib/rosett_ai/ui/base.rb', line 43 def text_direction(locale = nil) lang = locale || ENV.fetch('LANG', 'en')[0, 2] RTL_LOCALES.include?(lang) ? :rtl : :ltr end |