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 Command||Description|
|-0||Secify a record separator|
|-a||Autosplit mode with -n or -p|
|-c||Check Syntax only|
|-d||Set debugging flags|
|-e ‘command’||Execute one line of script|
|-F pattern||split() pattern with autosplit|
|-i [extension]||Edit ARGV files in place|
|-Idirectory||Specify $LOAD_PATH directory|
|-Kkcode||Specify chracter set|
|-l||Enable line-ending processing|
|-n||Assume while gets();……. end loop around script|
|-p||Assume 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.