I'm looking to write a method that creates an array of a fixed length (in my case 12) from any array it is provided of arbitrary length (though the length will always be 12 or less) by repeating the objects in order.
So for example given the array a:
a = [1, 2, 3, 4]
I would want to have returned:
a = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]
Another example:
b = ["peach", "plumb", "pear", "apple", "banana", "orange"]
Would return:
b = ["peach", "plumb", "pear", "apple", "banana", "orange", "peach", "plumb", "pear", "apple", "banana", "orange"]
And so on. If given an array with 12 objects, it would just return the same array.
The methods I've written to accomplish this so far have been very ugly and not very Rubyish; interested in how others would handle this.
Thanks in advance.