# File lib/lowline.rb, line 69
  def ask q, opts={}
    default_s = case opts[:default]
      when nil; nil
      when ""; " (enter for none)"
      else; " (enter for #{opts[:default].inspect})"
    end

    tail = case q
      when /[:?]$/; " "
      when /[:?]\s+$/; ""
      else; ": "
    end

    while true
      prompt = [q, default_s, tail].compact.join
      if Ditz::has_readline?
        ans = Readline::readline(prompt)
      else
        print prompt
        ans = STDIN.gets.strip
      end
      if opts[:default]
        ans = opts[:default] if ans.blank?
      else
        next if ans.blank? && !opts[:empty_ok]
      end
      break ans unless (opts[:restrict] && ans !~ opts[:restrict])
    end
  end