You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: public_key.rb
    path of file: ./repos/vagrant/plugins/guests/esxi/cap
    
    the code of the file until where you have to start completion: # Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1

require "tempfile"

require "vagrant/util/shell_quote"

module VagrantPlugins
  module GuestEsxi
    module Cap
      class PublicKey
      
        def self.insert_public_key(machine, contents)
          comm = machine.communicate
          contents = contents.strip << "\n"

          remote_path = "/tmp/vagrant-insert-pubkey-#{Time.now.to_i}"
          Tempfile.open("vagrant-esxi-insert-public-key") do |f|
            f.binmode
            f.write(contents)
            f.fsync
            f.close
            comm.upload(f.path, remote_path)
          end

          comm.execute <<
    
        def self.insert_public_key(machine, contents)
          comm = machine.communicate
          contents = contents.strip << "\n"

          remote_path = "/tmp/vagrant-insert-pubkey-#{Time.now.to_i}"
          Tempfile.open("vagrant-esxi-insert-public-key") do |f|
            f.binmode
            f.write(contents)
            f.fsync
            f.close
            comm.upload(f.path, remote_path)
          end

          comm.execute <<-EOH.gsub(/^ {12}/, "")
            set -e
            SSH_DIR="$(grep -q '^AuthorizedKeysFile\s*\/etc\/ssh\/keys-%u\/authorized_keys$' /etc/ssh/sshd_config && echo -n /etc/ssh/keys-${USER} || echo -n ~/.ssh)"
            mkdir -p "${SSH_DIR}"
            # NB in ESXi 7.0 we cannot change the /etc/ssh/keys-root directory
            #    permissions, so ignore any errors.
            chmod 0700 "${SSH_DIR}" || true
            cat '#{remote_path}' >> "${SSH_DIR}/authorized_keys"
            chmod 0600 "${SSH_DIR}/authorized_keys"
            rm -f '#{remote_path}'
          EOH
        end