Check out example codes for "brew update ruby". It will help you in understanding the concepts better.

Code Example 1

$ brew update
$ brew install ruby-build
$ brew install rbenv

$ rbenv install 2.7.0
$ rbenv global 2.7.0

Learn ReactJs, React Native from akashmittal.com