Class: DumpUtilities
- Inherits:
-
Object
- Object
- DumpUtilities
- Defined in:
- lib/DumpUtilities.rb
Class Method Summary collapse
Class Method Details
.font_dump(buffer) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/DumpUtilities.rb', line 22 def DumpUtilities.font_dump(buffer) #treat buffer as a set 8 bit wide characters s="" c=0 buffer.each_byte do |byte| s<<sprintf(";char %02x\n",c>>3) if c%8==0 s<<sprintf("%08b\n",byte).tr("1","#").tr("0"," ") c+=1 end s end |
.hex_dump(buffer) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/DumpUtilities.rb', line 3 def DumpUtilities.hex_dump(buffer) s="" (0..(buffer.length/16)).each {|line_number| lhs="" rhs="" start_byte=line_number*16 line=buffer[start_byte..start_byte+15] if line.length>0 then line.each_byte {|byte| lhs+= sprintf("%02X ", byte) rhs+= (byte%128).chr.sub(/[\x00-\x1f]/,'.') } lhs+=" "*(16-line.length)*3 s+=sprintf("%02X\t%s %s\n",start_byte,lhs,rhs) end } s end |