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

Hello all,

I'm pretty new to ruby, but have some background in Java, and very little
C(++) and suchlike.
I'm currently - as a "learning-by-doing"-project - creating a simple
text-based interface for running (more or less) arbitrary programs.
I decided on a simple tree-based structure for the menu itself, however I'm
a bit stuck on the hook between my interface, and the program running behind
it.

In order to not couple my interface too tightly to my program running behind
it, I'd really like for my interface to not know what it's actually
interfacing with.
Basically, I just figured I could take a leaf from the
Functional-programming style and give my TextInterface a method to call when
I told it to:
def call_action
  if(@action_method)
    send(@action_method)
  end
end

which works fine, as long as my method is defined "in the wild":

def foo
  puts "foo called"
end

interface.set_action(:foo)
interface.call_action => foo called

but, how do I handle it if the method is an instance method on some object?
program = Program.new
interface.set_action(:program.foo)?
No variant of this works for me.

I realise I may be fundamentally wrong in my approach, so any tips would be
welcome. :-)

Regards,

Sen Andersen

------art_6267_5739096.1193239887626--