Vagrantfile that works on both arm64/amd64

When creating a Vagrantfile, is there any way to detect the architecture, such as arm64 vs amd64? I want to select generic/ubuntu2204 if the host is Intel, and also perk/ubuntu-2204-arm64 if the system is running on Apple Silicon.

I am experimenting with using QEMU on either macOS (intel) or macOS (arm64) using Appleā€™s hypervisor.framework. Also, if the default Virtualbox on Intel on Win/Mac/Linux is used, this should work as well.

Vagrant.configure("2") do |config|
  HOMEBREW_PREFIX = ENV['HOMEBREW_PREFIX'] || '/usr/local'
  if RUBY_PLATFORM == "x86_64-darwin"
    config.vm.box = "generic/ubuntu2204"
    config.vm.provider "qemu" do |qe|
      qe.ssh_port = "50025" # change ssh port as needed
      qe.qemu_dir = "#{HOMEBREW_PREFIX}/share/qemu"
      qe.arch = "x86_64"
      qe.machine = "q35,accel=hvf"
      qe.net_device = "virtio-net-pci"
    end
  elsif RUBY_PLATFORM =~ /arm64.?-darwin\d\d$/
    config.vm.box = "perk/ubuntu-2204-arm64"
    # use defaults except for ssh_port
    config.vm.provider "qemu" do |qe|
      qe.ssh_port = "50026" # change ssh port as needed
    end
  end
end