def dump(data)
lines = data.to_s.scan(/.{1,16}/m)
max_offset = (offset + data.size) / 256
max_offset_width = max_offset.to_s.size + 1
max_hex_width = 49
out = template()
off = offset()
if index?
puts((' ' * max_offset_width) + " 0 1 2 3 4 5 6 7 8 9 A B C D E F\n")
end
lines.each_with_index do |line, n|
offset = off + n * 16
bytes = line.unpack("C*")
hex = bytes.map{ |c| "%0.2x" % c }.insert(8, '').join(' ')
plain = bytes.map do |c|
if ASCII_PRINTABLE.include?(c)
c = c.chr
else
color ? Code::WHITE + Code::STRIKE + '.' + Code::CLEAR : '.'
end
end.join('')
fill = [offset.to_s.rjust(max_offset_width), hex.ljust(max_hex_width), plain]
puts(out % fill)
end
end