Class: Idcf::Cli::Lib::Util::Input

Inherits:
Object
  • Object
show all
Defined in:
lib/idcf/cli/lib/util/input.rb

Overview

input

Class Method Summary collapse

Class Method Details

.qa(title, setting, nd = '') ⇒ String

qa

Parameters:

  • title (String)
  • setting (Hash)
  • nd (String) (defaults to: '')

Returns:

  • (String)


14
15
16
17
18
19
20
21
# File 'lib/idcf/cli/lib/util/input.rb', line 14

def qa(title, setting, nd = '')
  loop do
    v = qa_setting_list(setting)
    qa_puts_question(title, nd, v)
    result = qa_answer_input(v, nd)
    return result unless result.empty?
  end
end

.qa_answer_input(list, nd = '') ⇒ String

qa_answer_input

Parameters:

  • list (Array)
  • nd (String) (defaults to: '')

Returns:

  • (String)


28
29
30
31
32
33
34
35
36
# File 'lib/idcf/cli/lib/util/input.rb', line 28

def qa_answer_input(list, nd = '')
  loop do
    res    = STDIN.gets.strip
    result = res.empty? ? nd : res
    return result if qa_answer?(result, list)
    puts "from this [#{list.join('/')}]"
    ''
  end
end