title: Howto pass a class name as a variable to another class in ruby
body: <p>I'm trying to learn to create a multi class program in ruby. I coded an Engine class and some other classes like city, street, etc. and am having problems in passing the class name as a variable to other classes. The code below throws the error: "City.rb:15:in 'intro': undefined local variable or method game' for # (NameError)". I understand the problem in a way, but I don't think that city needs to know anything about 
  game object, I think it only has to get it and pass it back. But appearantly I have a misunderstanding about how to pass variables (especially the class name) between classes. What is wrong in my design?</p>
  
  <pre><code>#Game.rb
  require './City.rb'
  class Engine
    def initialize(city_name, street_name, budget)
      @city = City.new(city_name)
      @city.read_name()
      play(@city, :intro, self)
    end
  
    def play(place, next_step, engine)
      while true
        next_step = place.method(next_step).call(place, next_step, engine)
      end
    end
  end
  
  game = Engine.new("Casablanca", "Costanza Boulvard", 200)
  
  #City.rb
  class City
    def initialize(city_name)
      @city_name = city_name
    end
  
    def read_name()
      puts &lt;&lt;-READ_NAME
      You are in a city called "#{@city_name}".
      READ_NAME
    end
  
    def intro(place, next_step, engine)
      puts "...."
      game.play(@street, :enter, engine)
    end
  end
  </code></pre>