class Speckle::List::PatternFilter

Public Class Methods

new(pattern, invert = false) click to toggle source
# File lib/speckle/list/pattern_filter.rb, line 4
def initialize(pattern, invert = false)
  @pattern = pattern
  @invert = invert
end

Public Instance Methods

run(item) click to toggle source
# File lib/speckle/list/pattern_filter.rb, line 9
def run(item)
  regex = Regexp.new(@pattern)
  matched = !item.match(regex).nil?
  if @invert
    matched = !matched
  end

  return [item] if matched
  return []
end