8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/image_search.rb', line 8
def self.search(options={})
query = "http://ajax.googleapis.com/ajax/services/search/images?"
first = true
options.each do |key, option|
if first then
query << "#{key}=#{option}"
first = false
else
query << "&#{key}=#{option}"
end
end
json = open(query).read()
hash = JSON.parse(json)
returnData = []
hash["responseData"]["results"].each do |data|
returnData.push OpenStruct.new(data)
end
return returnData
end
|