Ruby has public, protected and private methods. Public is the default.
Any code can call a public method.
Code inside the same class or a subclass can call a protected method, even on another object. One object can then compare itself with another of its kind.
Only the object itself can call a private method, with no receiver, meaning no object before the dot. Since Ruby 2.7, a literal self. also works.
send can still call a private method from outside, so visibility is not a security boundary.
class MyClass
def public_method; end
protected
def protected_method; end
private
def private_method; end
end
Rewriting in plainer words…
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.