Class: Tefil::PercentPacker
- Inherits:
-
TextFilterBase
- Object
- TextFilterBase
- Tefil::PercentPacker
- Defined in:
- lib/tefil/percentpacker.rb
Instance Method Summary collapse
Methods inherited from TextFilterBase
Constructor Details
This class inherits a constructor from Tefil::TextFilterBase
Instance Method Details
#process_stream(in_io, out_io) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/tefil/percentpacker.rb', line 2 def process_stream(in_io, out_io) in_io.each do |line| old_chars = line.split("") new_str = "" new_index = 0 old_index = 0 while old_index < old_chars.size if old_chars[old_index] == "%" new_str += [old_chars[(old_index + 1) .. (old_index + 2)].join].pack("H*") old_index += 2 else new_str += old_chars[old_index] end old_index += 1 new_index += 1 end out_io.print new_str end end |