In article <200602152248.43632.david / vallner.net>,
David Vallner  <david / vallner.net> wrote:
>D=C5=88a Streda 15 Febru=C3=A1r 2006 08:48 Phil Tomson nap=C3=ADsal:
>> The only way to really get it to work would be to remove_method before
>> doing the extend.  The problem with that is that remove_method doesn't wo=
>rk
>> in that context (removing singleton methods).
>>
>
>Not even in the singleton class?
>

I couldn't get it to work.  Maybe there's some way.

However, I've come up with another way of doing what I was trying to do.  
What I needed was a Simulation functionality (where the code is run) and a 
Translation functionality (where the code translated to another language).  
Since the user doesn't need to switch from one to the other in the same run it 
makes sense to inherit from a different class based on a commandline 
argument(or mixin a different module).  something along the lines of this 
very simplified example:

  class A #could be modules too
    def foo
       "A::foo" 
    end
  end
  class B
    def foo
       "B::foo" 
    end
  end

  superclass = if ARGV[0] == "B"
               B
             else
               A
             end

  class Demo < superclass
    #could use include module instead of inheritance of superclass
  end

  d = Demo.new 
  puts d.foo

ruby demo.rb    #=> A::foo  (default)
ruby demo.rb B  #=> B::foo

This should do what I want and it doesn't lead to extra calls as with
delegation/method_missing schemes which could slow things down  
a little bit.

Phil