Inside of a class, a method declared using:
class MyClass
def self.my_method
# some stuff...
end
end
Is a "class method". That means you can call it like so:
MyClass.my_method
It's also valid to have an "instance method" which is associated with a member of the class, not the class itself:
class MyClass
def my_method
# some stuff
end
end
In your case, I think your code in "some other code in here........" may have a syntax error and an extra end
statement, closing off the class too early and causing the def self.gameLogic(...)
to be invalid since it's outside of the class.
There is a visible error in the logic in which you created a class method (as described above) with a def self.gameLogic
but you're calling it as if it were an instance method with an instance of the class. You should call a class method as Cannibals.gameLogic(...)
, or declare gameLogic
as an instance method: def gameLogic(...)
within the class.