ruby-win32/lib/ruby/site_ruby/1.8/rubygems/user_interaction.rb
def choose_from_list(question, list)
      @outs.puts question
      list.each_with_index do |item, index|
        @outs.puts " #{index+1}. #{item}"
      end
      @outs.print "> "
      @outs.flush

      result = @ins.gets

      return nil, nil unless result

      result = result.strip.to_i - 1
      return list[result], result
    end
# Choose from a list of options.  +question+ is a prompt displayed
# above the list.  +list+ is a list of option strings.  Returns
# the pair [option_name, option_index].
Choose from a list of options.  +question+ is a prompt displayed
above the list.  +list+ is a list of option strings.
Choose from a list of options . + question + is a prompt displayed above the list . + list + is a list of option strings .
def choose_from_list(question, list)
      @outs.puts question
      list.each_with_index do |item, index|
        @outs.puts " #{index+1}. #{item}"
      end
      @outs.print "> "
      @outs.flush
      result = @ins.gets
      return nil, nil unless result
      result = result.strip.to_i - 1
      return list[result], result
    end
def choose_from_list ( question , list ) @outs . puts question list . each_with_index do | item , index | @outs . puts " #{index+1}. #{item}" end @outs . print "> " @outs . flush result = @ins . gets return nil , nil unless result result = result . strip . to_i - 1 return list [ result ] , result end
Choose from a list of options.
Choose from a list of options .
question
list