Sha256: fb5d24040c0be002175f134c45325e1e5860ec0ccd970e44f5d2591fb336e817

Contents?: true

Size: 566 Bytes

Versions: 6

Compression:

Stored size: 566 Bytes

Contents

#! /usr/bin/env ruby
# coding: utf-8

class Tefil::IndentConverter < Tefil::TextFilterBase
  def initialize(old_char, old_width, new_char, new_width, options)
    @old_width = old_width
    @new_width = new_width
    @old_char  = old_char 
    @new_char  = new_char 
    super(options)
  end

  def process_stream(in_io, out_io)
    in_io.readlines.each do |line|
      /^(#{@old_char}*)(.*)$/ =~ line
      indent = $1
      body = $2
      new_indent = indent.size * @new_width / @old_width
      out_io.puts "#{@new_char * new_indent}#{body}"
    end
  end
end


Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
tefil-0.1.5 lib/tefil/indentconverter.rb
tefil-0.1.4 lib/tefil/indentconverter.rb
tefil-0.1.3 lib/tefil/indentconverter.rb
tefil-0.1.2 lib/tefil/indentconverter.rb
tefil-0.1.1 lib/tefil/indentconverter.rb
tefil-0.1.0 lib/tefil/indentconverter.rb