I need to generate sequences of labels that look like "ABC1" and "XYZ9" -- always three letters followed by a single digit. I want both parts of the label to increment logically, and always be the exact format and length.
I started with:
sequence(:code) { |n| "ABC#{n}" }
That was fine, but after the ninth label (ABC9) it went to (ABC10), violating my formatting, and only producing 10 (or 9?) values.
A quick fix of using the sequence for the letters and hard-coding one digit makes my rollover problem not occur for 26^3 => 17,576 instances, which might be okay. But, I really want some variability in the digit as well. A random digit would probably be good enough...but I want all the available values.
I thought about a few somewhat kludgy ways of building the string from one or two sequences to get comprehensive values always matching the format, but they seemed clunky.
Is there an elegant way in FactoryBot to build a sequenced string with a fixed-width letter segment followed by a fixed-width numeric segment that produces all possible values?