Sha256: bf2494cb5e7603588820b5e48b5273a24cad5b14fbabb8d0a58c14c1e3786593

Contents?: true

Size: 690 Bytes

Versions: 3

Compression:

Stored size: 690 Bytes

Contents

class DumpUtilities
  
  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
  
  def DumpUtilities.font_dump(buffer)
  #treat buffer as a set 8 bit wide characters
  s=""
  buffer.each_byte do |byte| 
      s<<sprintf("%08b\n",byte).tr("1","#").tr("0"," ")
  end
  s
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dsktool-0.4.1 lib/DumpUtilities.rb
dsktool-0.4.2 lib/DumpUtilities.rb
dsktool-0.5.1 lib/DumpUtilities.rb