Class: Seekr::Occurrence
- Inherits:
-
Object
- Object
- Seekr::Occurrence
- Includes:
- Client
- Defined in:
- lib/seekr/occurrence.rb
Constant Summary collapse
- PER_PAGE =
100
Constants included from Client
Instance Method Summary collapse
- #all(options = {}) ⇒ Object
- #all_paginated(options = {}) ⇒ Object
-
#initialize(monitor_id) ⇒ Occurrence
constructor
A new instance of Occurrence.
Methods included from Client
Constructor Details
#initialize(monitor_id) ⇒ Occurrence
Returns a new instance of Occurrence.
7 8 9 |
# File 'lib/seekr/occurrence.rb', line 7 def initialize(monitor_id) @monitor_id = monitor_id end |
Instance Method Details
#all(options = {}) ⇒ Object
11 12 13 |
# File 'lib/seekr/occurrence.rb', line 11 def all(={}) get("/search_results", params.merge()) end |
#all_paginated(options = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/seekr/occurrence.rb', line 15 def all_paginated(={}) [:page] = 1 response = get_search_results_json() iterate = !(response['search_results'].size < PER_PAGE) while iterate do [:page] += 1 next_page_response = get_search_results_json()['search_results'] break if next_page_response.size.zero? response['search_results'].concat(next_page_response) iterate = !(next_page_response.empty? || next_page_response.size < PER_PAGE) end JSON.dump(response) end |