Ruby access modifiers

Ruby access modifiers.

  1. Public
  2. private
  3. protected

In Ruby access modifiers apply only to methods.

1. Public : public methods can be accessed by the all the objects of parent and child class.

2. Protected : Protected methods can be accessed by the method of the class o the subclass. Protected methods cannot be invoked outside the class.

3. Private : Private methods can only be invoked by all other methods of the same class.