>>>>> "P" == Peter Schueller <peter.schueller / solution-x.com> writes:

P>     def initialize(c)
P>         super(c)
P>     # need something here, like A::foo(c) ??
P>         puts "Initialized B: #{c}"
P>     end

 Well, you can use an alias something like


pigeon% cat b.rb
#!/usr/bin/ruby
class A
   def initialize(b)
      puts "Initialized A: #{b}"
   end

   # need to call this from B
   def foo(a)
      puts "Foo A: #{a}"
   end
end

# my derived class
class B < A
   if method_defined?(:foo) && !method_defined?(:foo_a)
      alias foo_a foo
   end
   def initialize(c)
      super(c)
      # need something here, like A::foo(c) ??
      foo_a(c)
      puts "Initialized B: #{c}"
   end

   def foo(d)
      puts "Foo B: #{d}"
   end
end

x = B.new(10)
x.foo(20)
pigeon%
 
pigeon% b.rb
Initialized A: 10
Foo A: 10
Initialized B: 10
Foo B: 20
pigeon% 


Guy Decoux