When a class contains another class declaration that needs to be called (these classes are in separate files), that class must include class declaration using require keyword. require keyword pulls in Ruby code from a file outside current file. For example, there are two files, Shape (shape.rb) and Circle (circle.rb) classes in the same directory. Circle class contains Shape class declaration. So, Circle class needs to include Shape class using require ./shape.rb.
There are three possible cases a file requires another file:
Those files in the same directory.
A file requires another file that in a subdirectory of current directory.
A file requires another file that in up one level of current directory.
Currently, this feature only supports for association class in the same directory. The extension uses require_relative instead of require keyword. The remaining cases will be handled in the future release.
*Note that this feature also affects generalization (inheritance), interface, and other relationship between classes.
When a class contains another class declaration that needs to be called (these classes are in separate files), that class must include class declaration using
require
keyword.require
keyword pulls in Ruby code from a file outside current file. For example, there are two files, Shape (shape.rb
) and Circle (circle.rb
) classes in the same directory. Circle class contains Shape class declaration. So, Circle class needs to include Shape class usingrequire ./shape.rb
.There are three possible cases a file requires another file:
Currently, this feature only supports for association class in the same directory. The extension uses
require_relative
instead ofrequire
keyword. The remaining cases will be handled in the future release.*Note that this feature also affects generalization (inheritance), interface, and other relationship between classes.