Sha256: cb3c3541a8e998fd37fd220d9b7077511b6ce583025f8216ab5967e02287ba19

Contents?: true

Size: 444 Bytes

Versions: 4

Compression:

Stored size: 444 Bytes

Contents

class Tefil::LineSubstituter < Tefil::TextFilterBase
  def initialize(old_str, new_str, options = {})
    @old_str  = old_str
    @old_str  = /#{old_str}/ if options[:regexp]
    @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

4 entries across 4 versions & 1 rubygems

Version Path
tefil-0.1.5 lib/tefil/linesubstituter.rb
tefil-0.1.4 lib/tefil/linesubstituter.rb
tefil-0.1.3 lib/tefil/linesubstituter.rb
tefil-0.1.2 lib/tefil/linesubstituter.rb