Class: Legion::TTY::Components::InputBar

Inherits:
Object
  • Object
show all
Defined in:
lib/legion/tty/components/input_bar.rb

Instance Method Summary collapse

Constructor Details

#initialize(name: 'User', reader: nil) ⇒ InputBar

Returns a new instance of InputBar.



9
10
11
12
13
# File 'lib/legion/tty/components/input_bar.rb', line 9

def initialize(name: 'User', reader: nil)
  @name = name
  @reader = reader || build_default_reader
  @thinking = false
end

Instance Method Details

#clear_thinkingObject



27
28
29
# File 'lib/legion/tty/components/input_bar.rb', line 27

def clear_thinking
  @thinking = false
end

#prompt_stringObject



15
16
17
# File 'lib/legion/tty/components/input_bar.rb', line 15

def prompt_string
  "#{Theme.c(:accent, @name)} #{Theme.c(:primary, '>')} "
end

#read_lineObject



19
20
21
# File 'lib/legion/tty/components/input_bar.rb', line 19

def read_line
  @reader.read_line(prompt_string)
end

#show_thinkingObject



23
24
25
# File 'lib/legion/tty/components/input_bar.rb', line 23

def show_thinking
  @thinking = true
end

#thinking?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/legion/tty/components/input_bar.rb', line 31

def thinking?
  @thinking
end