From: GGarramuno@... (GGarramuno) Date: 2004-03-15T11:44:34+09:00 Subject: Embedding Ruby, part 2 Thanks Guy and Kent. Working perfectly. I have the 3d program maya running ruby code and ruby also running MEL code (maya's scripting language). Now, what I would like to do is to see if I can make the syntax of mixing ruby and mel a tad nicer. 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" } which would then call something like (or even better a callback on the = operator, as I have about 200 commands like ls): def ls(*args) MEL("ls",*args) end For example, in Perl, I could do: perl -e "sub ls($) { print @_,\"\n\"; \"aa\" }; $a = ls -type; print $a" Output: -type aa In the above example, ls -type would be interpreted as a string parameter to be passed to ls, which is what I would like. The user would be unaware he is calling a routine and external command (nor would he have to learn a new syntax). Is there any way I can achieve this sort of seamless add-on to ruby?