DelegateClass vs. Extending

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,
0600)

      # ...

      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.

···

--
Posted via http://www.ruby-forum.com/.