How to Run Ruby Code

For running Ruby on your laptop, you first need to check whether ruby is installed or not. So open up Command Line or Terminal and type in ruby –version if this returns something like ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin20]. Then you have ruby installed on your system. Then your good to go and run Ruby on your computer otherwise you first need to install it on your system. Ruby can be downloaded from here – Download Ruby Programming Language.

Ruby can be simply run on a computer using ruby [options] [–] [program filename] [agruments] command, do note that in this command each one of component which is inside square brackets is optional so you may or may not use these.

Let’s see what options can be used in this command for running Ruby.

Option for Ruby Running CommandDescription
-0Secify a record separator
-aAutosplit mode with -n or -p
-cCheck Syntax only
-dSet debugging flags
-e ‘command’Execute one line of script
-F patternsplit() pattern with autosplit
-i [extension]Edit ARGV files in place
-IdirectorySpecify $LOAD_PATH directory
-KkcodeSpecify chracter set
-lEnable line-ending processing
-nAssume while gets();……. end loop around script
-pAssume loop like -n but print line also like sed

I hope that this article helps you to understand how to run ruby. If in case, you have some query and want to ask me then do comment below.

Gagan

Hi, there I'm founder of ComputerScienceHub(Started this to bring useful Computer Science information just at one place). Personally I've been doing JavaScript, Python development since 2015(Been long) - Worked upon couple of Web Development Projects, Did some Data Science stuff using Python. Nowadays primarily I work as Freelance JavaScript Developer(Web Developer) and on side-by-side managing team of Computer Science specialists at ComputerScienceHub.io

Leave a Reply

Your email address will not be published. Required fields are marked *

Recent Posts