I was looking at DelegateClass example:
class Tempfile < DelegateClass(File)
# constant and class member data initialization…
def initialize(basename, tmpdir=Dir::tmpdir)
# build up file path/name in var tmpname...
@tmpfile = File.open(tmpname, File::RDWR|File::CREAT|File::EXCL,
# ...
super(@tmpfile)
# below this point, all methods of File are supported...
end
# ...
end
and was wondering what is the advantage of doing this and not just
extending the File class? Thanks.