Class: Xail::ReplaceFilter

Inherits:
AbstractFilter show all
Defined in:
lib/xail/filter.rb

Instance Method Summary collapse

Methods inherited from AbstractFilter

#filterName

Constructor Details

#initialize(regexp) ⇒ ReplaceFilter

Returns a new instance of ReplaceFilter.



172
173
174
# File 'lib/xail/filter.rb', line 172

def initialize(regexp)
  @regexp = regexp
end

Instance Method Details

#streamLine(line) ⇒ Object



176
177
178
179
180
181
182
183
# File 'lib/xail/filter.rb', line 176

def streamLine(line)
  # why fold when you can iterate
  final = line
  @regexp.each_pair do |patt,val|
    final.gsub!(patt,val)
  end
  final
end