Describe the environment variables present in Ruby.
Describe the environment variables present in Ruby.
Answer
Environment variables can be directly accessed by using ENV hash. Environment variables can be directly read or written to by using the index operator supplied with a string argument. The child processes of ruby script only are affected by writing ruby environment variables.
Ex:
#!/us/bin/envy ruby
# Print some variables puts ENV['PATH'] puts ENV['EDITOR']
# Change a variable then launch a new program ENV['EDITOR'] = 'edit'
Environment variables can be set by using Set TEST=value
Environment Variables Used by Ruby
RUBYOPT - To add command line switches.
RUBYPATH - To list the path when used with the -S switch on the command line.
RUBYPATH will be added to the paths searched when looking for Ruby scripts. The paths in RUBYPATH precede the paths listed in PATH.
RUBYLIB – The paths list will be added to the path list of Ruby that uses for searching libraries including the program with the require method. The paths in RUBYLIB will be searched before other directories.
Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website.
If you are using this website then its your own responsibility to understand the content of the website