[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

subclassing question

Jason Wold

1/29/2006 6:13:00 PM

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 = MyClass.new(10,10,0,0)
ensure
Ncurses.endwin
end

puts foo.class # this should return MyClass

# ./test
=> 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