Ruby extensions and programming libraries

Commonly used Ruby command-line

By Ruby, Ruby extensions and programming libraries No Comments
Commonly used Ruby command-line switches
SwitchDescriptionExample of usage
-cChecks the syntax of a program file without executing the programruby -c c2f.rb
-wGives warning messages during program executionruby -w c2f.rb
-eExecutes the code provided in quotation marks on the command lineruby -e ‘puts “Code demo!”‘
-lLine mode: prints a newline after every line of outputruby -le ‘print “+ newline!”‘
-rnameRequires the named featureruby –rprofile
-vShows Ruby version information and executes the program in verbose moderuby –v
–versionShows Ruby version informationruby –-version
-hShows information about all command-line switches for the interpreterruby –h

Difference between require and load

By Posts, Ruby, Ruby extensions and programming libraries No Comments

is more abstract than load. Strictly speaking, you don’t require a file; you require a feature. And typically, you do so without even specifying the extension on the filename. To see how this works, change this line in test.rb

 load "test.rb"

to this:

 require "./test"

When you run test.rb, you get the same result as before, even though you haven’t supplied the full name of the file you want loaded.