Class: Wikidata::SearchResponse

Inherits:
Response
  • Object
show all
Defined in:
lib/wikidata/search_response.rb

Instance Method Summary collapse

Methods inherited from Response

#initialize, #inspect

Constructor Details

This class inherits a constructor from Wikidata::Response

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/wikidata/search_response.rb', line 9

def empty?
  @_empty ||= @raw.body['query'].nil?
end

#next_page_offsetObject



18
19
20
21
# File 'lib/wikidata/search_response.rb', line 18

def next_page_offset
  return if empty?
  @raw.body['continue']['sroffset']
end

#resultsObject



4
5
6
7
# File 'lib/wikidata/search_response.rb', line 4

def results
  return [] if empty?
  @_results ||= Wikidata::Item.find(raw_ids).results
end

#total_hitsObject



13
14
15
16
# File 'lib/wikidata/search_response.rb', line 13

def total_hits
  return if empty?
  @raw.body['query']['searchinfo']['totalhits']
end