What is the correct way to run Ruby code from the terminal?

What is the correct way to run Ruby code from the terminal?

I need to execute a few lines of Ruby code directly from the terminal, but I can’t find the right parameter for it.

Can you explain how to do this using the Ruby console or other methods?