I need to run a few lines of Ruby code from terminal, but I can't find the needed parameter for it.
Can you explain how to do this?
Open Interactive Ruby If you're using macOS open up Terminal and type irb, then hit enter. If you're using Linux, open up a shell and type irb and hit enter. If you're using Windows, open Interactive Ruby from the Ruby section of your Start Menu.
In this case, it's a Ruby file to be executed with the Ruby interpreter. To mark the file as executable, run the command chmod +x test. rb. This will set a file permission bit indicating that the file is a program and that it can be run.
You can start it by typing irb in your shell and hitting enter. Its name is short for “Interactive Ruby Shell”, and yes, it is another kind of shell: Just like the shell running in your terminal irb is also a program that interactively waits for you to type something, and hit enter.
If Ruby is installed, then
ruby yourfile.rb
where yourfile.rb
is the file containing the ruby code.
Or
irb
to start the interactive Ruby environment, where you can type lines of code and see the results immediately.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With