Module: Enumerable

Defined in:
lib/tagen/core/enumerable.rb

Instance Method Summary collapse

Instance Method Details

#grep_values(*patterns, &blk) ⇒ Array

Returns an array of every element in enum for each pattern === element

Examples:


a = %w[aa ab bb cc]
a.grep_values(/a./, "bb")   -> ["aa", "ab", "bb"]

Returns:



10
11
12
13
14
# File 'lib/tagen/core/enumerable.rb', line 10

def grep_values(*patterns, &blk)
  patterns.each.with_object([]) {|pat,m|
    m.push *grep(pat, &blk)
  }
end