class Expletive::Undump
Public Class Methods
new(in_io=$stdin, out_io=$stdout)
click to toggle source
# File lib/expletive/filters.rb, line 48 def initialize(in_io=$stdin, out_io=$stdout) @in = in_io @out = out_io end
Public Instance Methods
handle_escape()
click to toggle source
# File lib/expletive/filters.rb, line 66 def handle_escape nextc = @in.getc case when nextc == '\\' @out.write "\\" when nextc == 'n' @out.write "\n" when nextc =~ /\h/ otherc = @in.getc hex = nextc + otherc @out.write hex.to_i(16).chr else raise "Dont know what to do with \\ #{nextc}" end end
run()
click to toggle source
# File lib/expletive/filters.rb, line 53 def run until @in.eof? ch = @in.getc if ch == "\n" # do nothing elsif ch != "\\" @out.write ch.chr else handle_escape end end end