Sha256: 08406502790340b5d29c3210a099f587d41a4d16e222fc87c52c86a41507ee80
Contents?: true
Size: 732 Bytes
Versions: 1
Compression:
Stored size: 732 Bytes
Contents
require 'open-uri' require 'rest_client' require 'json' module Wikiwhat class Call # Make a string that is the URL for the API call for text-based requests. # Call the API and parse the returning JSON object. def self.call_api(title, options={}) title = URI::encode(title) options[:prop] ? prop = "&prop=#{options[:prop]}" : '' options[:rvprop] ? rvprop = "&rvprop=content" : rvprop = '' options[:img_list] ? img_list = "&generator=images" : img_list = '' options[:iiprop] ? iiprop = "&iiprop=url" : iiprop = '' JSON.parse(RestClient.get "http://en.wikipedia.org/w/api.php?action=query#{prop}&titles=#{title}&format=json&redirects#{img_list}#{rvprop}#{iiprop}") end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
wikiwhat-0.0.2 | lib/wikiwhat/api_call.rb |