The following code recursively loops through an array providing we add a conditional statement e.g.

def cycle(a, i=0)
puts a.join
cycle(a + [a.shift], i+1) if i < 20
end

cycle '10000'.split(//).map &:to_s

output:

10000
00001
00010
00100
01000
10000
00001
00010
00100
01000
10000
00001
00010
00100
01000
10000
00001
00010
00100
01000
10000


# or

c2 =->(x,i=0){p x.join; d.call x+[x.shift],i+1 if i<20}
c2.call '10000'.split(//).map &:to_s

# or

def c3(a,i=0); p a.join; c3(a+[a.shift],i+1) if i<20 end
c3 '10000'.split(//).map &:to_s

# or without recursion
out = 10.times.map {a = a[1..-1] + [a[0]]}
# or
out = 10.times.map {a[1..-1].concat [a[0]]}
# or
out = (0..10).map {a[1..-1].concat [a[0]]}

Notes:
1) While attempting an infinite loop within irb1.9.1 an error occurred after ... 7656 levels...
2) While attempting an infinite loop within cycle.rb the following error was observed after 7693 levels "cycle': stack level too deep (SystemStackError)"

Read more: http://feeds.dzone.com/~r/dzone/snippets/~3/zRwwM0Lal2g/11093