What if you could run your entire Ruby program with just one simple command instead of typing it all out?
Why Running scripts with ruby command? - Purpose & Use Cases
Imagine you wrote a Ruby program saved as a file, but you try to run it by copying and pasting the code line by line into the terminal.
This takes a long time and you might miss some lines or make mistakes.
Running code manually line by line is slow and easy to mess up.
You lose time and can't easily repeat the same steps exactly.
It's frustrating and error-prone.
Using the ruby command lets you run the whole script file at once.
This runs your program quickly, correctly, and every time the same way.
copy line1 copy line2 copy line3 ...
ruby my_script.rb
You can run your entire Ruby program instantly and reliably with a simple command.
When you write a calculator program in Ruby, running it with ruby calculator.rb lets you test all calculations at once instead of typing each step manually.
Running scripts manually is slow and error-prone.
The ruby command runs whole files quickly and reliably.
This makes testing and using your Ruby programs easy and repeatable.