Is the relative path to the file from the current execution directory
Assume we have this directory structure: /home/stackoverflow/script.rb
If you are inside /home/stackoverflow and execute the script like
ruby script.rb then
__FILE__ will output
If you are inside /home then it will output
Very useful to get the path of the script in versions prior to 2.0 where
__dir__ doesn't exist.
__FILE__ is not equal to
__dir__ is not a constant but a function
__dir__ is equal to
Contains the name of the script being executed.
Is the same as
__FILE__ if you are executing that script.
The process number of the Ruby running this script
Contains the subpattern from the corresponding set of parentheses in the last successful pattern matched, not counting patterns matched in nested blocks that have been exited already, or nil if the last pattern match failed. These variables are all read-only.
Command line arguments given for the script. The options for Ruby interpreter are already removed.
The standard input. The default value for $stdin
The standard output. The default value for $stdout
The standard error output. The default value for $stderr
The current standard error output.
The current standard output
The current standard input
The hash-like object contains current environment variables. Setting a value in ENV changes the environment for child processes.