I've run up against something I thought I knew how to solve, but...
class IO
def outputbit(bit)
@c = (@c << 1) | bit
@bitcount += 1
if ((@bitcount % 8) == 0)
putc(c)
c = 0
end
end
end
OK, horribly inefficient, but still. I have extended IO. Now, how
do I get IO to initialize @c and @bitcount properly? Do I
class IO
rename :initialize :orig_initialize
def initialize(*args)
@c = 0
@bitcount = 0
old_initialize(args)
end
end
and will this be picked up by open and so on, or do I do something else?
And should the solution go in the CodingInRuby on the Wiki?
Hugh