Module: HashExtension

Included in:
Hash
Defined in:
lib/watirmark/extensions/ruby_extensions.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) extract(*keys) Also known as: slice

Returns a hash that only contains pairs with the specified keys



3
4
5
6
7
8
# File 'lib/watirmark/extensions/ruby_extensions.rb', line 3

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