A
Art Gillespie
Hi,
New to Ruby and to the list. I've looked through pickaxe and through
the ruby source code and haven't figured this one out.
With the built-in File class, if I derive from it and call a class
method (e.g., open) what I get back is an instance of my derived
class:
class IFFFile < File
end
f =3D IFFFile.open("media.iff", "r")
f.class =3D> "IFFFile"
How does one do this with their own class methods?
class A
def A.open
#how do we know here if the message recipient is a subclass of A?
#i.e., can't we generalize it so that it is, in effect, class.new?
A.new
end
end
Many thanks for any pointers to what I'm missing.
Art
New to Ruby and to the list. I've looked through pickaxe and through
the ruby source code and haven't figured this one out.
With the built-in File class, if I derive from it and call a class
method (e.g., open) what I get back is an instance of my derived
class:
class IFFFile < File
end
f =3D IFFFile.open("media.iff", "r")
f.class =3D> "IFFFile"
How does one do this with their own class methods?
class A
def A.open
#how do we know here if the message recipient is a subclass of A?
#i.e., can't we generalize it so that it is, in effect, class.new?
A.new
end
end
Many thanks for any pointers to what I'm missing.
Art