Method: Whatsa::CLI#get_dmb_choice

Defined in:
lib/whatsa/cli.rb

#get_dmb_choice(disambig) ⇒ Object



108
109
110
111
112
113
114
115
116
117
118
# File 'lib/whatsa/cli.rb', line 108

def get_dmb_choice(disambig)
  display_dmb(disambig)
  choice = nil
  loop do
    choice = gets_command
    in_choices = disambig.choices.detect { |c| c.downcase == choice }
    break if in_choices || choice.to_i > 0
    puts "Hmm... I don't think that's a valid choice. Try again!"
  end
  disambig.choose_article(choice)
end