Module: RubyAnything::Filterable

Defined in:
lib/ruby-anything/filterable.rb

Instance Method Summary collapse

Instance Method Details

#filter(text) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/ruby-anything/filterable.rb', line 3

def filter(text)
  patterns = text.split(/\s+/).map do |word|
    /#{word}/i
  end

  select do |e|
    patterns.empty? || patterns.all? { |p| p =~ e }
  end
end