Оператор Ruby splat / collect *
может вам помочь. Он работает путем преобразования массивов в выражения, разделенные запятыми, и наоборот.
Сбор параметров в массив
*collected = 1, 3, 5, 7
puts collected
# => [1,3,5,7]
def collect_example(a_param, another_param, *all_others)
puts all_others
end
collect_example("a","b","c","d","e")
# => ["c","d","e"]
Разделение массива на параметры
an_array = [2,4,6,8]
first, second, third, fourth = *an_array
puts second # => 4
def splat_example(a, b, c)
puts "#{a} is a #{b} #{c}"
end
param_array = ["Mango","sweet","fruit"]
splat_example(*param_array)
# => Mango is a sweet fruit