I am in the process of creating a little codewriting training game for giggles. The game shall be in ruby, and I want the user to write code and then let the game look at it and what the code returns, a little like in _why’s hackety (but from a cli).
I can’t find a way to do this, do you know how?
Take a look at
eval, which interprets a String as ruby code. If you’re wondering how to write the text editor portion, that is more difficult (and beyond the scope of this website). The simplest solution would be use to readline in the standard library, which lets you create an IRB-like prompt.