Environment vars

February 8, 2007 by pedro mota

ENV is the hash that contains environment variables:\r\n\r\nENV.collect { |key, val| puts \"#{key} ==> #{val}\" }\r\nENV.each_pair { |key, val| puts \"#{key} ==> #{val}\" }\r\n\r\nNeed to know $HOME of the current user (needed for config files, say)?\r\n\r\nputs ENV['HOME'] if `ENV.has_key?('HOME')`\r\n``````` `puts ENV['HOME'] if` `````` `ENV.key?('HOME')`\r\n````` `puts ENV['HOME']` ```` `if ENV.include?('HOME')`\r\n``` `puts ENV['HOME']` `` `if ENV.member?('HOME')` `` ``` ```` ````` `````` ```````

© 2018 | Follow on Twitter | pedro mg & Hugo