    # File lib/rubygems/user_interaction.rb, line 146
        def ask_yes_no(question, default=nil)
          unless @ins.tty? then
            if default.nil? then
              raise Gem::OperationNotSupportedError,
                    "Not connected to a tty and no default specified"
            else
              return default
            end
          end

          qstr = case default
                 when nil
                   'yn'
                 when true
                   'Yn'
                 else
                   'yN'
                 end

          result = nil

          while result.nil?
            result = ask("#{question} [#{qstr}]")
            result = case result
            when /^[Yy].*/
              true
            when /^[Nn].*/
              false
            when /^$/
              default
            else
              nil
            end
          end

          return result
        end