Class: CloudSearch::SearchResponse

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



3
4
5
# File 'lib/cloud_search/search_response.rb', line 3

def body
  @body
end

#current_pageObject (readonly)

Returns the value of attribute current_page.



33
34
35
# File 'lib/cloud_search/search_response.rb', line 33

def current_page
  @current_page
end

#http_codeObject

Returns the value of attribute http_code.



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

def http_code
  @http_code
end

#items_per_pageObject Also known as: page_size



24
25
26
# File 'lib/cloud_search/search_response.rb', line 24

def items_per_page
  @items_per_page || 10
end

#total_pagesObject (readonly)

Returns the value of attribute total_pages.



34
35
36
# File 'lib/cloud_search/search_response.rb', line 34

def total_pages
  @total_pages
end

Instance Method Details

#found?Boolean Also known as: any?

Returns:

  • (Boolean)


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

def found?
  hits > 0
end

#hitsObject Also known as: total_entries



10
11
12
# File 'lib/cloud_search/search_response.rb', line 10

def hits
  _hits["found"] || 0
end

#offsetObject



36
37
38
39
# File 'lib/cloud_search/search_response.rb', line 36

def offset
  return 0 unless found?
  (@current_page - 1) * items_per_page
end

#resultsObject



6
7
8
# File 'lib/cloud_search/search_response.rb', line 6

def results
  _hits["hit"] || []
end