Class: Hash
Overview
filter hash example: tags = [ ‘foo’, ‘bar’, ‘fii’ ] useableTags = tags.filter( ‘fii’ )
Instance Method Summary collapse
Instance Method Details
#filter(*args) ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'lib/monkey_patches.rb', line 60 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 |