Self tells Ruby that this is a method that acts on the Class and not on an instance of the class. You can see a great example in the screenshot. In the first, I define a class method, using Self. Self is one way to define a class method. Another two ways are, def Class.new_method or def Class << new_method. When I run the program, the output of puts Test.output shows a capitalized „Test.“ The output method has worked itself upon the ABCD variable INSIDE of the Test Class.
But what would happen if I tried to run Test.output without having defined a Class Method using self? Well then, the method would fail. But where it would succeed? On an INSTANCE of Test. Because now I’ve actually written an Instance Method. And that’s what you see in the Test2 Class.