title: Parent and child class hierarchy
body: <p>So I have many child classes that will inherit from a parent class. I've been playing around with instance variables <code>@</code> and class variables <code>@@</code> and I have yet to be able to achieve with them what I want. What I want actually works with the code below but it doesn't seem DRY at all. Any suggestions on how I can refactor this?</p>
  
  <pre><code>class Planet
      def has_color?(color)
          self.color == color
      end
  
      def has_position?(position)
          self.position == position
      end
  end
  
  class Mars &lt; Planet
      def color
          "red"
      end 
  
      def position
          4
      end
  end
  
  class Earth &lt; Planet
      def color
          "blue"
      end
  
      def position
          3
      end
  end
  </code></pre>
  
  <p>What I hope to achieve</p>
  
  <pre><code>&gt;&gt; Mars.has_color?("red")
  true
  
  &gt;&gt; Earth.position
  3
  </code></pre>