update_rubygems (Multiruby)

    # File lib/multiruby.rb, line 404
      def self.update_rubygems
        warn "  Determining latest version for rubygems"
        html = URI.parse(GEM_URL).read

        versions = html.scan(/href="rubygems-update-(\d+(?:\.\d+)+).gem/i).flatten
        latest = versions.sort_by { |s| s.scan(/\d+/).map { |s| s.to_i } }.last

        Multiruby.in_versions_dir do
          file = "rubygems-#{latest}.tgz"
          unless File.file? file then
            warn "    Fetching rubygems-#{latest}.tgz via HTTP."
            File.unlink(*Dir["rubygems*"])
            File.open file, 'w' do |f|
              f.write URI.parse(GEM_URL+"/"+file).read
            end
          end
        end

        Multiruby.in_install_dir do
          FileUtils.rm_rf Dir["*"]
        end
      end