module LogCabin::Modules::Filter

Use regex to filter out from a list of matches

Public Instance Methods

filter_helper(list) click to toggle source
# File lib/prospectus/helpers/filter.rb, line 6
def filter_helper(list)
  return list unless @filter_regex
  new_list = list.select { |x| x =~ @filter_regex }
  return new_list unless new_list.empty?
  raise("No matches found in list: #{@filter_regex} / #{list}")
end

Private Instance Methods

filter(regex) click to toggle source
# File lib/prospectus/helpers/filter.rb, line 15
def filter(regex)
  @filter_regex = regex
end