title: how to get class from which a method has been defined in ruby?
body: <p>Having the snippet below:</p>
  
  <pre><code>class Foo
    def initialize
      puts self.class
    end
  end
  
  class Bar &lt; Foo
    def bark
      puts self.class
    end
  end
  
  class Fizz &lt; Bar
  end
  
  Fizz.new.bark
  </code></pre>
  
  <p>This snippet will output two times <code>Fizz</code> (<a href="https://repl.it/repls/PrimaryStarkEmbed" rel="nofollow noreferrer">live example</a>). I would like to find something to replace <code>self.class</code> which allows this program to output <code>Foo</code> (from initialize) and then <code>Bar</code> (from bark).</p>
  
  <p>My current solution is to hardcode function name, but I'd like something more dynamic.</p>