class Wikidata::SearchResponse

Public Instance Methods

empty?() click to toggle source
# File lib/wikidata/search_response.rb, line 9
def empty?
  @_empty ||= @raw.body['query'].nil?
end
next_page_offset() click to toggle source
# File lib/wikidata/search_response.rb, line 18
def next_page_offset
  return if empty?
  @raw.body['continue']['sroffset']
end
results() click to toggle source
# File lib/wikidata/search_response.rb, line 4
def results
  return [] if empty?
  @_results ||= Wikidata::Item.find(raw_ids).results
end
total_hits() click to toggle source
# File lib/wikidata/search_response.rb, line 13
def total_hits
  return if empty?
  @raw.body['query']['searchinfo']['totalhits']
end

Protected Instance Methods

raw_ids() click to toggle source
# File lib/wikidata/search_response.rb, line 25
def raw_ids
  return if empty?
  @raw.body['query']['search'].map{|r| r['title'] }
end
raw_results() click to toggle source
# File lib/wikidata/search_response.rb, line 30
def raw_results
  return [] if empty?
  @raw.body['query']['search']
end