title: Class variable access from top level
body: <p>I am a complete beginner to Ruby. I am working on Lesson 45 of Learn Ruby the Hard Way currently and am creating a game similar to Zork and Adventure. </p>
  
  <p>I have created a structure where I am creating 'scenes' in different files and requiring all the scenes in one file where I have an engine/map that ensures if the current scene does not equal 'finished' that it runs 'X' scene's 'enter' method.</p>
  
  <p>However I have two issues:
  1) I keep getting a error saying 'Warning class variable access from top level'
  2) Even though the script is running I get</p>
  
  <pre><code>ex45.rb:30:in `play': undefined method `enter' for nil:NilClass (NoMethodError) from ex45.rb:59:in
  </code></pre>
  
  <p>The following is all of my code from each file. My apologies if it's a long read, but I would love to know why I am getting these two errors and what I can do to fix them. </p>
  
  <p>Ex45.rb:</p>
  
  <pre><code>require "./scene_one.rb"
  require "./scene_two.rb"
  require "./scene_three.rb"
  
  @@action = SceneOne.new
  @@action_two = SceneTwo.new
  @@action_three = SceneThree.new
  
  class Engine
  
      def initialize(scene_map)
          @scene_map = scene_map
      end
  
      def play()      
          current_scene = @scene_map.opening_scene()
          last_scene = @scene_map.next_scene('finished')
  
          while current_scene != last_scene
              next_scene_name = current_scene.enter()
              current_scene = @scene_map.next_scene(next_scene_name)
          end
  
          current_scene.enter()
      end
  end
  
  
  class Map
  
      @@scenes = {
          'scene_one' =&gt; @@action,
          'scene_two' =&gt; @@action_two,
          'scene_three' =&gt; @@action_three
      }
  
      def initialize(start_scene)
          @start_scene = start_scene
      end
  
      def next_scene(scene_name)
          val = @@scenes[scene_name]
          return val
      end
  
      def opening_scene()
          return next_scene(@start_scene)
      end
  end
  
  a_map = Map.new('scene_one')
  a_game = Engine.new(a_map)
  a_game.play()
  </code></pre>
  
  <p>scene_one.rb:</p>
  
  <p>class SceneOne</p>
  
  <pre><code>  def enter
      puts "What is 1 + 2?"
      print "&gt; "
  
      answer = $stdin.gets.chomp
  
      if answer == "3"
          puts "Good job"
          return 'scene_two'
      else
          puts "try again"
          test
      end
    end
  
  end
  </code></pre>
  
  <p>scene_two.rb</p>
  
  <pre><code>class SceneTwo
  
      def enter
          puts "1 + 3?"
          print "&gt; "
  
          action = $stdin.gets.chomp
  
          if action == "4"
              return 'scene_three'
          else
              puts "CANNOT COMPUTE"
          end
      end
  
  end
  </code></pre>
  
  <p>scene_three.rb</p>
  
  <pre><code>class SceneThree
  
      def enter
          puts "This is scene three"
      end
  
  end
  </code></pre>
  
  <p>Thanks in advance!</p>