title: Is Ruby private method accessible in sub class?
body: <p>I have code as follows:</p>
  
  <pre><code>class A
    private
    def p_method
      puts "I'm a private method from A"
    end
  end
  
  class B &lt; A
    def some_method
      p_method
    end
  end
  
  b = B.new
  b.p_method    # =&gt; Error: Private method can not be called
  b.some_method # =&gt; I'm a private method from A
  </code></pre>
  
  <p><code>b.some_method</code> calls a private method that is defined in class <code>A</code>. How can a private method be accessed in the class where it is inherited? Is this behavior the same in all object oriented programming languages? How does Ruby do encapsulation?</p>