Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/rubydns/extensions/hexdump.rb
Instance Method Summary collapse
Instance Method Details
#hexdump ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/rubydns/extensions/hexdump.rb', line 5 def hexdump i = 1 out = StringIO.new out.puts "Size: #{self.size}" while (self.length > 16*(i-1)) a = self.slice(16*(i-1)..(16*i)-1) out.printf("%06x: %4.4x %4.4x %4.4x %4.4x %4.4x %4.4x %4.4x %4.4x ", (i-1)*16, *a.unpack("n16")) out.printf("|%s|\n", a.tr("^\040-\176",".")) i += 1 end return out.string end |