iterator pattern built in Ruby