Class: Hash
Overview
Monkey Patch for Hash
Instance Method Summary collapse
-
#filter(*args) ⇒ Hash
add a filter function to Hash Class.
Instance Method Details
#filter(*args) ⇒ Hash
add a filter function to Hash Class
80 81 82 83 84 85 86 87 |
# File 'lib/monkey_patches.rb', line 80 def filter( *args ) if( args.size == 1 ) args[0] = args[0].to_s if args[0].is_a?( Symbol ) select { |key| key.to_s.match( args.first ) } else select { |key| args.include?( key ) } end end |