You can use #each_key.