From: Bob Showalter Date: 2006-01-17T01:51:15+09:00 Subject: Re: DANGER ! Ruby-Newbie ahead: How to access binary files Meino Christian Cramer wrote: > Hi, > > There is a file on my HD, which was written by a C program. The C > program wrotes the contents of an array of structures (each array > element was made from the same structure) to that file. > > Since accessing that file looks like a very low level and > "procedure-based" thing to me I would be very interested how this job > can be done in a most ruby-like, objectoriented way. You need to know the format of the structure and its size. You can then use IO#read to read bytes from the file into a string and String#unpack to extract the individual fields from the structure. Of course, all of this should be encapsulated into a class :-)