Austin Ziegler
4/2/2005 12:48:00 AM
On Apr 1, 2005 6:14 PM, Joe Van Dyk <joevandyk@gmail.com> wrote:
> I'm writing some code that generates an image file based off
> either a binary file or shared memory.
>
> I figure that I need three functions:
>
> generate_image_from_file # public
> generate_image_from_shmem # public
> generate_image # private?
>
> The user would call either generate_image_from_file or
> generate_image_from_shmem. Once the data has been loaded, both
> functions would call generate_image to write the image to a file
> somewhere.
>
> Would this be best written as a class inside a module? Or a set of
> functions inside a module? I'm not really storing any data, and
> there's no point in keeping the object around after the image is
> generated.
I think that you're looking at it wrong. The way that I'd do it is
to have generate_image be the public version that accepts either a
binary block of data (e.g., a binary String) or an IO-like object
that responds to #read.
Then, look at putting a shmem wrapper that responds to #read.
-austin
--
Austin Ziegler * halostatue@gmail.com
* Alternate: austin@halostatue.ca