Last-input entered on command line

Hi Everyone,

I'm writing a console application to teach myself Ruby. The app displays a
task, eg "write a one-liner that returns [1,2,3,4]" and I write a ruby
statement that evaluates to the requested object.

for example:

write a one-liner that outputs [1, 2, 3, 4]
(1..4).inject() {|m,i| m << i}

The problem I'm having is that, when I make a mistake or fat-finger
something, it's annoying to retype my code instead of just hitting the up
arrow (a la irb or any other command line utility I've used) and having my
previously entered statement appear. Then I can just fix my mistake and hit

So, I'm trying to implement that functionality--hit the up arrow while the
program is running, and you get the last entered statement. I've googled and
stack-overflowed and have found some libraries I never new about (HighLine,
for example), but haven't been able to figure out how to make this work.

Any ideas?