Self is not so much a concept as an object. The default object.
There is always only one self, but what that is may change. Like a narrator in a book with multiple first-person identities.
puts "top level"
puts "self is #{self}"
class C
puts "Class Definition Block:"
puts "self is #{self}"
def self.x
puts "Class method C.x:"
puts "self is #{self}"
end
def m
puts "Instance Method C#x:"
puts "self is #{self}"
end
x
end
c = C.new
c.m
this will return
top level
self is main
Class Definition Block:
self is C
Class method C.x:
self is C
Instance Method C#x:
self is #<C:0x0000010086c4e0>
So in the instance method call, the hex tells us self is an instance of C.
Within Singleton Methods self is the object to which that method belongs