Hi all,
having to design a usable environment for non
extremely-computer-literate users, I’d like them to fire
up irb with some default options via an alias and write:
Here, the calculate() method would (in my dreams) inspect
the caller’s environment, find out the values of foo, bar
and baz, and use them in its calculation. Of course, in
the real thing the parameters would be a few more, and
some of them could be omitted. Is there a decent way to
accomplish this?
Thanks,
Luigi
P.S. Of course I will accept suggestions for an altogether
different way of enabling people to use my code. But
the above seems an interesting problem in its own right,
and now I got curious
P.P.S. RTFM answers are welcome as well, when coupled with
the relevant reference (I did skim through the pickaxe
book, but without luck—the reflection thing only
seems to apply to the current frame…)
“Luigi Ballabio” luigi.ballabio@fastwebnet.it schrieb im Newsbeitrag
news:pan.2003.06.24.14.18.21.963302@fastwebnet.it…
Hi all,
having to design a usable environment for non
extremely-computer-literate users, I’d like them to fire
up irb with some default options via an alias and write:
Here, the calculate() method would (in my dreams) inspect
the caller’s environment, find out the values of foo, bar
and baz, and use them in its calculation. Of course, in
the real thing the parameters would be a few more, and
some of them could be omitted. Is there a decent way to
accomplish this?
If you can guess the variable names you can do:
b = eval ‘x’
A simple solution to your problem is to use instance variables like this:
“Luigi Ballabio” luigi.ballabio@fastwebnet.it schrieb im Newsbeitrag
news:pan.2003.06.24.14.18.21.963302@fastwebnet.it…
Hi all,
having to design a usable environment for non
extremely-computer-literate users, I’d like them to fire
up irb with some default options via an alias and write:
“Luigi Ballabio” luigi.ballabio@fastwebnet.it schrieb im Newsbeitrag
news:pan.2003.06.24.17.07.18.904137@fastwebnet.it…
“Luigi Ballabio” luigi.ballabio@fastwebnet.it schrieb im Newsbeitrag
news:pan.2003.06.24.14.18.21.963302@fastwebnet.it…
Hi all,
having to design a usable environment for non
extremely-computer-literate users, I’d like them to fire
up irb with some default options via an alias and write: