There appears to be no documentation for Ruby’s readline support. What’s worse, it’s written in C, so you can’t (easily) read the source to find out its interface.
By peering at IRB’s source, however, I was able to construct the following:
require 'readline'
loop do
line = Readline::readline('> ')
Readline::HISTORY.push(line)
puts "You typed: #{line}"
end