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.



174
175
176
# File 'lib/xail/filter.rb', line 174

def initialize(regexp)
  @regexp = regexp
end

Instance Method Details

#streamLine(line) ⇒ Object



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

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