Class: Hash
Direct Known Subclasses
Instance Method Summary collapse
-
#extract(*keys) ⇒ Object
(also: #slice)
Returns a hash that only contains pairs with the specified keys.
Instance Method Details
#extract(*keys) ⇒ Object Also known as: slice
Returns a hash that only contains pairs with the specified keys
46 47 48 49 50 51 |
# File 'lib/watirmark/extensions/ruby_extensions.rb', line 46 def extract(*keys) keys = keys[0] if keys[0].is_a?(Array) hash = self.class.new keys.each { |k| hash[k] = self[k] if has_key?(k) } hash end |