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.



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

def body
  @body
end

#current_pageObject (readonly)

Returns the value of attribute current_page.



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

def current_page
  @current_page
end

#http_codeObject

Returns the value of attribute http_code.



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

def http_code
  @http_code
end

#items_per_pageObject Also known as: page_size, limit_value



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

def items_per_page
  @items_per_page || 10
end

#total_pagesObject (readonly)

Returns the value of attribute total_pages.



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

def total_pages
  @total_pages
end

Instance Method Details

#found?Boolean Also known as: any?

Returns:

  • (Boolean)


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

def found?
  hits > 0
end

#has_pagination?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/cloud_search/search_response.rb', line 29

def has_pagination?
  hits > items_per_page
end

#hitsObject Also known as: total_entries



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

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

#offsetObject



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

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

#resultsObject



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

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