Private Methods
Private methods are only able to be called from the class which they are defined inside.
class SomeClass
def public_method
puts "This can be called from anywhere"
end
private
def private_method
puts "This can only be called from inside the context of the current object"
end
end
object = SomeClass.new
object.public_method
# "This can be called from anywhere"
object.private_method
`<main>': private method `private_method' called for #<SomeClass:0x000000010dfd8528> (NoMethodError)
Did you mean? private_methods