class IDSequence
attr_reader :current
def initialize(start=0,digits=6,base=36)
@id, @chars, @base = start, digits, base
end
def next
s = (@id+=1).to_s(@base)
@current = "0"*(@chars-s.length) << s
end
end
id = IDSequence.new
1234.times{ id.next }
puts id.current
puts id.next
9876543.times{ id.next }
puts id.current
source
share