Class: RosettAi::Ui::Base

Inherits:
Object
  • Object
show all
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.

Direct Known Subclasses

Gtk4, Kde, Qt6, Tui

Constant Summary collapse

RTL_LOCALES =
['ar', 'he', 'fa', 'ur'].freeze

Instance Method Summary collapse

Instance Method Details

#accessible?Boolean

Returns:

  • (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

Raises:

  • (NotImplementedError)


32
33
34
# File 'lib/rosett_ai/ui/base.rb', line 32

def announce(message)
  raise NotImplementedError, "#{self.class}#announce not implemented"
end

#display_table(headers, rows) ⇒ Object

Raises:

  • (NotImplementedError)


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

Raises:

  • (NotImplementedError)


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

Raises:

  • (NotImplementedError)


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

Raises:

  • (NotImplementedError)


28
29
30
# File 'lib/rosett_ai/ui/base.rb', line 28

def show_spinner(message, &)
  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