1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
require "strscan"
class RPStringScanner < StringScanner
if ENV["DEBUG"] || ENV["TALLY"] then
def getch
c = super
where = caller.drop_while { |s| s =~ /(getch|nextc).$/ }.first
where = where.split(/:/).first(2).join(":")
if ENV["TALLY"] then
d getch:where
else
d getch:[c, where]
end
c
end
def scan re
s = super
where = caller.drop_while { |x| x =~ /scan.$/ }.first
where = where.split(/:/).first(2).join(":")
if ENV["TALLY"] then
d scan:[where]
else
d scan:[s, where] if s
end
s
end
def d o
STDERR.puts o.inspect
end
end
end
|