title: Ruby Error - undefined local variable or method
body: <p>I have a Ruby class that contains two methods. The first method opens the file, and the second method works with the data read from the file. </p>
  
  <p>Note that this is not the original code that I am working on, but one to demonstrate the issue I'm having.</p>
  
  <pre><code>class Example
  
    def load_json(filepath)
       require 'json'
       file = File.read(path-to-file)
       file_data = JSON.parse(file)
    end
  
    def read_data(tag)
      load_json(tag)
      #code to read and work with the data from file_data 
    end
  
  end
  </code></pre>
  
  <p>When I try that, it gives me the following error:</p>
  
  <pre><code>`file_data': undefined local variable or method `file_data'
  </code></pre>
  
  <p>I'm a total Ruby beginner.</p>