title: How to access variable from outside class in another file
body: <p>My file structure is as follows:</p>
  
  <pre><code>Main/
  Games/ 
     roulette.rb
  casino.rb
  wallet.rb
  player.rb
  </code></pre>
  
  <p>I have a wallet class that holds a money value in the class like so.</p>
  
  <pre><code>class Wallet
      attr_accessor :money
      def initialize
          @money = 0
      end
  end
  </code></pre>
  
  <p>I then have a player class that inherits from the Wallet class</p>
  
  <pre><code>class Player &lt; Wallet
  
      attr_accessor :name
      def initialize
          super()
          @name = nil
          get_user_info
      end
  </code></pre>
  
  <p>I then have a Casino class that inherits from Player like so</p>
  
  <pre><code>class Casino &lt; Player
      def initialize
          binding.pry
          puts @money, @name
      end
  </code></pre>
  
  <p>I have also used <code>require_relative</code> to pull in both files thinking that would give me access to their global variables <code>@money, @name</code>. </p>
  
  <p>If I am inside the <code>roulette.rb</code> file here is my code I wrote just to see if it would have a value.</p>
  
  <pre><code>require_relative '../wallet.rb'
  
  class Roulette
      def initialize
          puts @wallet
      end
  end
  </code></pre>
  
  <p>How would I go about getting access to these variables in the casino class? Thanks for the help.</p>