Class: TTY::Prompt

Inherits:
Object
  • Object
show all
Defined in:
lib/monkey_patches/tty/prompt.rb

Instance Method Summary collapse

Instance Method Details

#clear_listObject



30
31
32
33
34
35
36
# File 'lib/monkey_patches/tty/prompt.rb', line 30

def clear_list
  @done = true
  # @list = nil
  unsubscribe_list
  # 2 is for the prompt message
  print(TTY::Cursor.clear_lines(GitPrompt::SELECT_OPTIONS_PER_PAGE + 2, :up))
end

#invoke_select(object, question, *args, &block) ⇒ Object

FIXME This introduces dependencies to tty-prompt v0.23.1 original - github.com/piotrmurach/tty-prompt/blob/master/lib/tty/prompt.rb#L226-L250



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/monkey_patches/tty/prompt.rb', line 10

def invoke_select(object, question, *args, &block)
  options = Utils.extract_options!(args)
  choices = if args.empty? && !block
              possible = options.dup
              options = {}
              possible
            elsif args.size == 1 && args[0].is_a?(Hash)
              Utils.extract_options!(args)
            else
              args.flatten
            end

  @list = object.new(self, **options)
  @list.(question, choices, &block)
end

#unsubscribe_listObject



26
27
28
# File 'lib/monkey_patches/tty/prompt.rb', line 26

def unsubscribe_list
  self.unsubscribe(@list)
end