From: isambart@... (Vincent ISAMBART) Date: 2004-03-15T20:14:37+09:00 Subject: Re: Embedding Ruby, part 2 > Currently, I have a ruby C routine ( MEL(*args) ) that is able to > execute any command of MEL with ruby parameters and tranform its > return values to equivalent ruby constructs (String, arrays, etc). > > Thus, (dummy) user code now looks like: > > b = "joint" > 1000.times() > { > a = MEL("ls -type", b) > } > > What I would like to do would be to hide the use of the MEL() command, > in as seamless way as possible. What I ideally would like the user > type would be something like: > > b = "joint" > 1000.times() > { > a = ls -type b # or a = "ls -type b" > } what about the following : b = "joint" 1000.times() { a = ls(:type => b) } It would be more like standard Ruby and will certainly will be simpler to do. And to be able to call the MEL methods inside Ruby, you could do something like that : module Kernel def method_missing( symbol, *args ) # call the corresponding MEL function end end And if you do not want to 'pollute' the Kernel module, juste create a new module called MEL for example with method_missing. You would just have to call MEL.ls(:type => b) PS : I am not very good in Ruby and I am replying without having the time to check anything on a Ruby interpreter. I just hope it will be of some use :-). -- Vincent ISAMBART Maintainer of Ruby/GtkGLExt which is part of Ruby-GNOME2 - http://ruby-gnome2.sourceforge.jp/