Sha256: 29eb4c1ebc7d92a6f7f596b5c35ca2c372000b5994951e4b390aca73bf1d4bf7

Contents?: true

Size: 397 Bytes

Versions: 2

Compression:

Stored size: 397 Bytes

Contents

class Tefil::LineSubstituter < Tefil::TextFilterBase
  def initialize(old_str, new_str, options = {})
    @old_str  = old_str 
    @new_str  = new_str 
    @global = options[:global]
    super(options)
  end

  def process_stream(in_io, out_io)
    in_io.each do |line|
      method = :sub
      method = :gsub if @global
      out_io.puts line.send(method, @old_str, @new_str)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tefil-0.1.1 lib/tefil/linesubstituter.rb
tefil-0.1.0 lib/tefil/linesubstituter.rb