Ruby Hex Dumper - 10%
of CIS700 course grade
Assignment 2 - due by midnight, U Jul 20
Deduction for lateness is 10% per day for 5 days, then no credit.
Version 1.0 - last updated 6/22/2008
|
High-level applications such as word processors display the logical
contents of files, rather than their physical content. But
sometimes it is helpful to see the undisplayed parts of a file. The UNIX "od"
(octal dump) command will display a file as hex bytes ("od -x filename"),
but in many cases, it is also helpful to see which bytes are ASCII characters.
Please modify the HexDump.run method in this
Ruby program (a starter program) to display the hex values of every byte in a file.
The starter code will display file poem.txt like this::

The page after you complete the code, your program should display the file
formatted example this way:

RULES:
- Your program should display your name and the file name before displaying
file contents.
- The number of hex columns to display is 16.
- The line number must be shown on the left in octal.
- The ASCII values are shown on the left, followed by the "|" separator,
followed by the hex values. Line addresses, hex and ASCII columns must
be padded or justified so that they line up down the page exactly as shown
above.
- If the character to be displayed is not in the printable range (ASCII 32
- 127), display a . in the ASCII area.
- Space between hex columns, and mark the middle of the hex line with a
"-" exactly as shown. There should be an extra space between hex
columns 4 and 5, and between 12 and 13; this increases readability.
- Your program should offer to stop after every 20 lines of output.
- Your program should handle binary files. Test this by
dumping the Life.class file.
- At the end of the file, display the total bytes which were in the file.
TURN-IN:
The turn-in procedure for programming assignments is as follows:
- Create a folder with your emailID as its name. The folder
I would create would be pgpalmer; yours will be different.
- Copy your Ruby project and all test files into this folder.
- Create a .zip file of this folder.
- Test unarchiving the zip file to make sure it produces all your files and
directories, but in whatever folder the person unzipping chooses (such as, on
the Desktop).
- If correct, log into
Blackboard and turn in the
zip file (via file upload in your web browser). Please select SEND FILE
(and not SAVE FILE) in the Blackboard DropBox.