how to install ruby on mac code example

Example 1: install ruby and rails on mac

brew install rbenv ruby-build

# Add rbenv to bash so that it loads every time you open a terminal
echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.zshrc
source ~/.zshrc

# Install Ruby
rbenv install 2.6.6
rbenv global 2.6.6
ruby -v

Example 2: brew install ruby

brew install ruby

Example 3: install ruby

$ sudo apt-get install ruby-full

Example 4: install ruby mac

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"