New to programming and Ruby. I'm working with the iStock API and need to send a fileID to request information about files I have.
Example files I have that I need get to request info on iStock:
["iStock_000001053628Small.jpg", "iStock_000002270952Big_Web.mov", "ist2_7034929-blurred-commuter.jpg", iStock_000000042199Medium.jpg]
Working in irb, the code I send to iStock's API:
require 'xmlrpc'
parameters = {:apiKey=>"#", :fileID=>"1053628"}
server = XMLRPC::Client.new2( "http://api.istockphoto.com/webservices/xmlrpc")
server.call("istockphoto.image.getInfo", parameters)
Challenge: I need to extract the fileID numbers out of the array. This means I have to take all the zeros off the front of the file number. However, the file numbers differ in length and the number of zeros in the front differs for each image.
istock.each do |x|
result = ' '
x.scan(/\d+/) do |y|
if y.to_i > 4
result << y
end
puts result
end
end
000001053628
000002270952
7034929
000000042199
I'm not sure how to approach this problem because if I set up rules for the sets of 0's, there might be a time when the actual fileID also has these in it.