Help Me/Question What Are Your Favorite Commands To Execute Ruby Programs

jazzvaga

Well-Known Member
Guys,

What methods / commands / execution functions you use to deal with your code in Ruby Language?

Anything specific here or you simply code it in a normal sequence!
 

Oldwriter

Content Writer
Hello @jazzvaga,

What methods / commands / execution functions you use to deal with your code in Ruby Language?
Do you mean what are the command-line switches to use Ruby?

If you want to test a one-liner you can do it with the -e switch, with the format:

ruby -e '<your code here>'

for instance:

Code:
ruby -e 'puts "Hello WebmasterServe"'
If you want to interpret your program, you simply pass it to ruby in the command line:

ruby <your program's file path here>

Say you saved your program as the file wms.rb

Code:
puts "Hello WebmasterServe"
You would run it like:
Code:
ruby wms.rb
If you want to execute your program directly as any other program in your box, then you would add a shebang + ruby's interpreter path as your program's first line:

Code:
#!/usr/bin/ruby
puts "Hello WebMasterServe"
Then give it execution permission with CHMOD:
Code:
chmod +x wms.rb
And finally run it as you would do with any other program:
Code:
./wms.rb
 
Last edited:
Top