class Wikidata::Client
Constants
- DEFAULT_QUERY
Attributes
query[RW]
total_pages[RW]
Public Class Methods
new(query = {})
click to toggle source
# File lib/wikidata/client.rb, line 9 def initialize query = {} @query = DEFAULT_QUERY.merge(query) end
Public Instance Methods
response()
click to toggle source
# File lib/wikidata/client.rb, line 13 def response response_class.new api.get('', query) end
Private Instance Methods
api()
click to toggle source
# File lib/wikidata/client.rb, line 28 def api opts = Wikidata.options.merge url: Wikidata.settings.api.url Faraday.new(opts) do |faraday| faraday.request :url_encoded faraday.response :json, content_type: /\bjson$/ Wikidata.faraday.call faraday end end
response_class()
click to toggle source
# File lib/wikidata/client.rb, line 19 def response_class case @query[:action] when 'query' Wikidata::SearchResponse else Wikidata::Response end end