Class: Tefil::IndentConverter
- Inherits:
-
TextFilterBase
- Object
- TextFilterBase
- Tefil::IndentConverter
- Defined in:
- lib/tefil/indentconverter.rb
Overview
! /usr/bin/env ruby coding: utf-8
Instance Method Summary collapse
-
#initialize(old_char, old_width, new_char, new_width, options) ⇒ IndentConverter
constructor
A new instance of IndentConverter.
- #process_stream(in_io, out_io) ⇒ Object
Methods inherited from TextFilterBase
Constructor Details
#initialize(old_char, old_width, new_char, new_width, options) ⇒ IndentConverter
Returns a new instance of IndentConverter.
5 6 7 8 9 10 11 |
# File 'lib/tefil/indentconverter.rb', line 5 def initialize(old_char, old_width, new_char, new_width, ) @old_width = old_width @new_width = new_width @old_char = old_char @new_char = new_char super() end |
Instance Method Details
#process_stream(in_io, out_io) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/tefil/indentconverter.rb', line 13 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 |