>
> (1<<n).times.map{ | d | "%0{n}b" % d }
Oh I just forgot, maybe you need the "combinatoric" method ;)

n.times.inject( [ "" ] ){ |s,| s.map{ |e| [ e + "0", e + "1" ] }.flatten }