title: Undefined method for array
body: <p>So I'm receiving the error message "undefined method 'ip_histogram' for # (NoMethodError)" with the following code</p>
  
  <pre><code>class CommonLog
    def initialize(logfile)
      @logfile = logfile
    end
    def readfile
      @readfile = File.readlines(@logfile).map { |line|
        line.split()
      }
      @readfile = @readfile.to_s.split(" ")
    end
    def ip_histogram
      @ip_count = 0
      @readfile.each_index { |index|
        if (@readfile[index] =~ /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/ )
          puts @readfile[index]
          puts @ip_count += 1
        end
      }
    end
  end
  
  my_file = CommonLog.new("test_log")
  cleaned_file = my_file.readfile
  puts cleaned_file.ip_histogram
  </code></pre>
  
  <p>I'm trying to read the array in and check it with regex. It works if I take the code out of the method and just throw it into the main program, but I'd like to know why it doesn't work as a method.</p>