Niklas Backlund wrote:
>The "main loop" in the method that reads the file, reads
>a parameter on each line (for simplicity) according to a
>keyword-value scheme, and constructs the appropriate
>objects. However, some of the data I want to read are
>strings containing line breaks. I solved it by doing
>something along the lines of here documents, i e
>something like
>
>parameter value
>parameter value
>long-parameter WHATEVER
>  data
>  data
>WHATEVER
>parameter value
>...
>Is there a neat, "Ruby-way" of pulling this off? Or do I
>just have to reconsider my choice of file format?

Hmmm....my first cut (in pseudocode) would be:
for each line
  if it's a short parameter
     process that parameter
  else
     memorize the terminator
     read lines until you hit the terminator
     process that parameter
  end
end

You could extract the entire if/else into a 
method to keep the main loop simpler. Aside from 
Ruby's nice line-oriented input methods, I don't 
see any obvious opportunities to come up with a 
really cool Ruby-specific solution.

To get any more detailed, I think I'd need to 
know what kinds of objects you're creating based 
on what kinds of inputs.

Kevin