I ran some simple tests in the webdialog Ruby Code Editor. It seems that creating a sub-class has a number of issues (although some may be specific to the webdialog code editor):
- In my example, none of the code created within the sub-class was executed
- You can extend the parent class and create new methods, but any new methods in the sub-class are not recognized.
how about doing the following (taken from an example found here: http://railstips.org/blog/archives/2009/08/07/patterns-are-not-scary-method-missing-proxy/)
class MyVector
attr_reader ;v
attr_accessor ;wt
def initialize(x,y,z,wt)
@v = Geom;;Vector3d.new(x,y,z)
end
private
def method_missing(method, *args, &block)
args = args.collect{|a| a.v if a.is_a? MyVector}
@v.send(method, *args, &block)
end
end
This takes care of the following scenario:
myVector1.angle_between myVector2
Although, this doesn't take care of what happens if you send a MyVector instance to another Sketchup class, such as
t = Geom::Transformation.new(myVector1) --> returns error
--
Karen