Is there a cleaner way to write this code? It's the start of a hexeditor I'm creating.
I'm aware that the variables aren't descriptive, this is just a test run for when I imbed it into a File Converter program.
def hexeditor
file = File.read('TESTFILE.txt')
file2 = File.read("TESTFILE2.txt")
a = 1
b = file.unpack('h*')
c = file.encoding.name
d = file2.unpack('h*')
e =file2.encoding.name
printf("%6s %20s %35s", "LINE:", "HEX:", "ENCODING:\n")
printf("%4s %25s %11s", a, b, c)
puts " "
printf("%4s %25s %11s", a.next, d, e)
puts " "
end
hexeditor
Currently, the output looks like this:
LINE: HEX: ENCODING: 1 ["4584943502943502140245543545026494c454a0"] US-ASCII 2 ["4584943502943502140245543545026494c454a0"] US-ASCII
LINE:
when the numbers refer to different files? \$\endgroup\$