Posted by Simone Nicolo, Google SketchUp team.
Have you ever wondered how the various classes are organized in the ruby API?
Well, I recently created a diagram to show the objects hierarchy for the SketchUp Ruby API.
It can be found here and it provides an easy way to visualize relationships between SU API's various objects.
Below are some examples of ways in which the diagram can be used:
Example 1
In the diagram, it is evident that the Entity class has several subclasses which all inherit the Entity class methods. For example, the Face class can add an EntityObserver to its instances just by taking advantage of the inherited methods from the Entity class.
Example 2
It is also visually clear that I can get handles to different entities using Ruby. For example, if I want to obtain a handle to my current model, I can do so using Sketchup.active_model or Entity.model. The Entity.model method will work on any class that inherits from Entity.
Example 3
I can clearly visualize which classes have observers and which do not. For example, I can easily see that the View class has its own observer, while the camera class does not.
To keep it as simple as possible, some classes were not included in the diagram.
Hopefully this will help you better visualize the organization of the Ruby API elements.
Simone.
No comments:
Post a Comment