subclassing question

J

Jason Wold

------=_Part_21872_29476365.1138558380886
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

I'm trying to subclass Ncurses::WINDOW but it just seems to hijack my
class. My subclass' initialize never gets called. I can't add any new
methods.

# cat test
#!/usr/bin/ruby
begin
require 'rubygems'
rescue LoadError
ensure
require 'ncurses'
end

class MyClass < Ncurses::WINDOW

def initialize(arbstring)
puts lkjlkdsf # this should generate an error
end

end

Ncurses.initscr

begin
foo =3D MyClass.new(10,10,0,0)
ensure
Ncurses.endwin
end

puts foo.class # this should return MyClass

# ./test
=3D> Ncurses::Window



Two things wrong.
-initialize never gets called. If it did "puts lkjlkdsf" would generate an
error.

-"puts foo.class" returns Ncurses::WINDOW where I would expect MyClass.

As a side note, Ncurses::WINDOW doesn't even exist until Ncurses.initscr is
called. Perhaps it's dynamic nature is getting in the way?

Jason

------=_Part_21872_29476365.1138558380886--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,961
Messages
2,570,130
Members
46,689
Latest member
liammiller

Latest Threads

Top