-1

This method accepts a list of URLs:

Magick::ImageList.new("img1url", "img2url", "img3url")

I have this string "url1, url2, url3".

How can I feed the above method my list as separate arguments? I tried:

urls = urls.split(',')
Magick::ImageList.new(urls) # fails. It produces an array.

# fails. It produces "'img1url','img2url'".
# The comma is part of the string, but it should split method arguments.
urls = urls.split(',').join("','")
Magick::ImageList.new(urls)
dee
  • 1,848
  • 1
  • 22
  • 34

1 Answers1

4

* can expand the array to arguments:

urls = urls.split(', ')
Magick::ImageList.new(*urls)
Ry-
  • 218,210
  • 55
  • 464
  • 476
  • `Magick::ImageMagickError: no data returned 'http://7.jpg,8.jpg,9.jpg'` -- I cut short the urls. If I pass the images in individually, they work. The comma is still appearing inside the string... – dee May 24 '13 at 14:15
  • @dee: Oh, take out the space in `', '` then. Your sample string gave me the impression that they were separated by a space and a comma. – Ry- May 24 '13 at 14:19