Skip to content

Example: Generalization

Andrias Meisyal edited this page Oct 21, 2016 · 3 revisions

Generalization is mapped into inheritance. The classes in the lower hierarchy inherit all attributes and method from the higher hierarchy. This class is called as a subclass. The class in the higher hierarchy is called a superclass. For example,

Generalization

This extension will generate Ruby code of the class diagram above. Two separated files are shown as follow:

super_class.rb

class SuperClass
  def initialize()
  end

  def to_s
    "Your string representation of the object will be written here."
  end
end

sub_class.rb

class SubClass < SuperClass
  def initialize()
  end

  def to_s
    "Your string representation of the object will be written here."
  end
end

Constructor and a to string instance methods are generated by default.

Clone this wiki locally