Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/openstudio-standards/utilities/hash.rb
Overview
Add a “dig” method to Hash to check if deeply nested elements exist From: stackoverflow.com/questions/1820451/ruby-style-how-to-check-whether-a-nested-hash-element-exists
Instance Method Summary collapse
Instance Method Details
#dig(*path) ⇒ Object
4 5 6 7 8 |
# File 'lib/openstudio-standards/utilities/hash.rb', line 4 def dig(*path) path.inject(self) do |location, key| location.respond_to?(:keys) ? location[key] : nil end end |