I have successfully generated a ruby module from a compiled c++ library, but I want to add some ruby methods. For example one of the libraries returns a linked list of objects that you access via:
objects.get_first_object
objects.get_next_object
I would like to add a method so I can do
objects.each do |object|
...
end
so probably something like
def to_a
ret = Array.new
obj = objects.get_first_object
while obj
ret << obj
obj = objects.get_next_object
end
return ret
end
The question is not how to create the methods but how should I add them to the class?
Should I just open the classes and add the methods?
I was thinking of creating subclasses but that seems messy since there is inheritance involved, so I think if I do that I would have to re-create the inheritance?
If I decide to open the classes, what the best way to to that?