Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parsing a binary file in Ruby

Tags:

I need to be able to parse a binary file with Ruby. This file contains chunks of data that are found via a header that includes the file offset and length of each chunk.

How do I get the data out correctly? I've been unable so far to seek around in the file based on the offsets I read out since they come out in strings that I don't know how to convert to a format IO#seek understands.

Any help? A general way to convert the offset and length into something usable (like an integer or something) would be helpful.