I have provided an answer to a Stack Overflow question asking how this can be done in Ruby. I've also explained in a comment on the answer which suggests using Array#fill why this does not meet the exact need.
What should happen if the size is smaller than what currently set?
If the pad_to_length argument is less than or equal to the array's current size the array is returned unchanged. If it is larger, elements of the specified kind are pushed to the array until it reaches pad_to_length size and the modified array returned.