Sha256: 32661dde1220fd4f169a2521a72373576184a1a3454b7cf78701187d28368821

Contents?: true

Size: 561 Bytes

Versions: 4

Compression:

Stored size: 561 Bytes

Contents

class Tefil::PercentPacker < Tefil::TextFilterBase
  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
end

Version data entries

4 entries across 4 versions & 1 rubygems

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