Module: Dsu::Support::Ask

Instance Method Summary collapse

Instance Method Details

#ask_while(prompt, options: {}) ⇒ Object

rubocop:disable Lint/UnusedMethodArgument



9
10
11
12
13
14
15
16
17
18
# File 'lib/dsu/support/ask.rb', line 9

def ask_while(prompt, options: {}) # rubocop:disable Lint/UnusedMethodArgument
  loop do
    print prompt
    char = $stdin.getch
    puts char
    return char if yield(char)

    char
  end
end

#yes?(prompt, options: {}) ⇒ Boolean



20
21
22
23
24
25
26
27
28
29
# File 'lib/dsu/support/ask.rb', line 20

def yes?(prompt, options: {})
  auto_prompt = auto_prompt(prompt, options)

  unless auto_prompt.nil?
    puts prompt
    return auto_prompt
  end

  Thor::Base.shell.new.yes?(prompt)
end