title: How to deserialize multiple objects in ruby 1.8.7 lazily
body: <p>I need to serialize lots of objects to a file (multiple GBs). We have chosen to use Google's protocol buffers for other things in this project, so I thought I would use that to serialize the objects I receive from the wire. This seems to work:</p>
  
  <pre><code>File.open(file_name, 'ab') do |f|
    some_objects.each { |some_object|
      some_object.serialize(f)
    }
  end
  </code></pre>
  
  <p>The deserializtion is what is giving me issues. I have seen others do one object like this:</p>
  
  <pre><code>File.open(file_name, 'r') do |f|
    no = some_object.parse(f)
  end
  </code></pre>
  
  <p>But that only does one. I tried doing this:</p>
  
  <pre><code>File.open(file_name, 'r').each do |f|
    no = some_object.parse(f)
  end
  </code></pre>
  
  <p>But that raised this exception: </p>
  
  <pre><code>Uncaught exception: undefined method `&lt;&lt;' for false:FalseClass
  </code></pre>
  
  <p>I need to get all of them and lazily evaluate them. Any thoughts? Please feel free to give any advice on performace of this code since I'll be doing GBs of info. Thanks for your time.</p>
  
  <p>By the way, I know I need to upgrade my ruby version, but since this is an internal thing I haven't been able to get time from the boss to upgrade it.</p>
  
  <p>I am using <a href="https://github.com/codekitchen/ruby-protocol-buffers" rel="nofollow">ruby-protocol-buffers</a> </p>