class String

Public Instance Methods

hexdump() click to toggle source
# File lib/ffi-libav.rb, line 21
def hexdump
  buf = ""
  offset = 0
  words = self.unpack("N%d" % (self.length/4.0).ceil)
  until words.empty?
    line = words.shift(4).compact
    buf += sprintf("[%04x] " + ("%08x " * line.size) + "|%s|\n", 
                   offset * 16, *line, 
                   line.pack("N%d" % line.size).tr("^\040-\176","."))
    offset += 1
  end
  buf
end