# File lib/lowline.rb, line 177 def ask_for_selection stuff, name, to_string=:to_s puts "Choose a #{name}:" stuff.each_with_index do |c, i| pretty = case to_string when block_given? && to_string # heh yield c when Symbol c.send to_string when Proc to_string.call c else raise ArgumentError, "unknown to_string argument type; expecting Proc or Symbol" end puts " #{i + 1}) #{pretty}" end j = while true i = ask "#{name.capitalize} (1--#{stuff.size})" break i.to_i if i && (1 .. stuff.size).member?(i.to_i) end stuff[j - 1] end