Skip to content

Instantly share code, notes, and snippets.

@rbuck
Created September 27, 2012 14:07
Show Gist options
  • Save rbuck/3794199 to your computer and use it in GitHub Desktop.
Save rbuck/3794199 to your computer and use it in GitHub Desktop.
How to get a hash listing all Ruby globals
def get_globals
hash = {}
global_variables.sort.map do |symbol|
begin
value = eval ("#{symbol}")
hash[symbol] = value unless value.nil?
rescue
nil
end
end
hash
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment