title: Ruby initialize: why doesn't it execute my read instruction
body: <p>This is code from the day 3 of the Ruby section of 7 programming languages in 7 weeks. I can't get it to output anything if I don't write m.read just after m = RubyCsv.new</p>
  
  <p>Shouldn't the initialize method take care of that ?    </p>
  
  <p>To test you can use a simple rubycsv.txt file containing</p>
  
  <blockquote>
    <p>one, two</p>
    
    <blockquote>
      <p>1, 2</p>
    </blockquote>
  </blockquote>
  
  <p>And here is the ruby code:</p>
  
  <pre><code>module ActsAsCsv
  
  def self.included(base)
      base.extend ClassMethods
  end
  
  module ClassMethods
      def acts_as_csv
          include InstanceMethods
      end
  end
  
  module InstanceMethods
      def read
          @csv_contents = []
          filename = 'rubycsv.txt'
          file = File.new(filename)
          @headers = file.gets.chomp.split(', ')
          file.each do |row|
              @csv_contents &lt;&lt; row.chomp.split(', ')
          end
      end
  
      attr_accessor :headers, :csv_contents
  
      def initalize
          read
      end
  end
  end
  
  class RubyCsv
  include ActsAsCsv
  acts_as_csv 
  end
  
  m = RubyCsv.new
  **m.read** #this shouldn't be necessary according to the book
  puts m.headers.inspect
  puts m.csv_contents.inspect
  </code></pre>