Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/misc/hexdump.rb
Overview
hexdump.rb Copyright © 2010..2013 Carsten Bormann <[email protected]>
Instance Method Summary collapse
Instance Method Details
#hexdump(prefix = '', out = STDOUT) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/misc/hexdump.rb', line 5 def hexdump(prefix = '', out = STDOUT) i = 0 while i < length slice = byteslice(i, 16) out.puts '%s%-48s |%-16s|' % [prefix, slice.bytes.map { |b| '%02x' % b.ord }.join(' '), slice.gsub(/[^ -~]/mn, '.')] i += 16 end out end |