Paul Battley
5/11/2005 9:16:00 AM
> Here's a (long) one-liner to do the same, taking advantage of
> pack/unpack's "b" specifier:
>
> str.scan(/.{1,8}/m).map{ |s| s.reverse
> }.join.unpack('b*')[0].tr('01','-+').scan(/.{1,64}/).map{ |s| (s << ('
> ' * 64))[0,64]<< '_' }.join("\n")
OK, that *was* one line before I posted it. Let's try again:
str.scan(/.{1,8}/m).map{ |s| s.reverse }.
join.unpack('b*')[0].tr('01','-+').scan(/.{1,64}/).
map{ |s| (s << (' ' * 64))[0,64]<< '_' }.
join("\n")
Paul.