class FeedFilter::AdsFilters
Public Class Methods
new()
click to toggle source
# File lib/feedfilter/ads.rb, line 11 def initialize @filters=[] names=[ 'feedburner', 'feedflare' ] names.each do |name| logger.debug " add ads filter #{name}" b = BlockReader.from_file( "#{FeedFilter.root}/config/#{name}.txt").read ## Note: replace newline and space in string for regex (w/o spaces) ## Note: add multiline option and ignore case regexp = Regexp.new( b[0].gsub( /[\n ]/, '' ), Regexp::MULTILINE|Regexp::IGNORECASE ) @filters << [name, regexp] end end
Public Instance Methods
filter( text )
click to toggle source
# File lib/feedfilter/ads.rb, line 30 def filter( text ) @filters.each do |f| name = f[0] pattern = f[1] text = text.gsub( pattern ) do |m| # Note: m - match is just a regular string ## double check if it's true also if regex contains capture groups ??? puts "strip #{name}:" pp m '' end end # each filter text end