Class: DetailedInfo
- Inherits:
-
Object
- Object
- DetailedInfo
- Includes:
- GetInfo
- Defined in:
- lib/nation/detailed_info.rb
Overview
# API Documentation: www.mediawiki.org/wiki/API:Main_page
Instance Method Summary collapse
Instance Method Details
#get(nation_name) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/nation/detailed_info.rb', line 10 def get(nation_name) nation_name = nation_name.downcase.split.map(&:capitalize).join("_") api_endpoint = "https://en.wikipedia.org/w/api.php?action=query&format=json&prop=extracts&titles=#{nation_name}&formatversion=2&exsentences=10&exlimit=1&explaintext=1" response = get_api_info(api_endpoint) raise "Not detailed info found for country #{nation_name}" if response["query"]["pages"][0]["missing"] country_detailed_info = {"detailed_info": response["query"]["pages"][0]["extract"]} end |