Class: SearchResult

Inherits:
Object
  • Object
show all
Includes:
Paginateable
Defined in:
lib/mas/search_result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Paginateable

#first_record, #last_record, #page_size, #total_pages, #total_records

Constructor Details

#initialize(response, page: 1) ⇒ SearchResult

Returns a new instance of SearchResult.



6
7
8
9
# File 'lib/mas/search_result.rb', line 6

def initialize(response, page: 1)
  @raw_response = response
  @current_page = page
end

Instance Attribute Details

#current_pageObject (readonly)

Returns the value of attribute current_page.



4
5
6
# File 'lib/mas/search_result.rb', line 4

def current_page
  @current_page
end

#raw_responseObject (readonly)

Returns the value of attribute raw_response.



4
5
6
# File 'lib/mas/search_result.rb', line 4

def raw_response
  @raw_response
end

Instance Method Details

#firmsObject



11
12
13
14
15
# File 'lib/mas/search_result.rb', line 11

def firms
  return [] unless raw_response.status.ok?

  @firms ||= hits.map { |hit| FirmResult.new(hit) }
end