Creating a class syntax:
class ClassName
def MethodName( parameter )
@classVariable = parameter
end
end
class ClassName
def initialize(param1, param2)
@param1 = param1
@param2 = param2
end
end
You instantiate an object from a class with:
object = ClassName.new(parameters)
You can directly access the attributes or methods of a superclass with Ruby's built-in super keyword.
Super - When you call 'super' from inside a method, that tells Ruby to look in the superclass of the current class and find a method with the same name as the one from which super is called. If it finds it, Ruby will use the superclass' version of the method.
class SubClass < SuperClass
end
class DerivedClass < Base
def some_method
super(optional args)
# Some stuff
end
end
end