Class: GeoNamesAPI::ListEndpoint

Inherits:
Base show all
Defined in:
lib/geonames_api/list_endpoint.rb

Instance Attribute Summary

Attributes inherited from Entity

#request_params

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

all, find, where

Methods inherited from Entity

#create_attribute, #initialize, #marshal_dump, #marshal_load, #parse_attr, #parse_response, #set_default_type

Constructor Details

This class inherits a constructor from GeoNamesAPI::Entity

Class Method Details

.endpoint_returns_list?Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/geonames_api/list_endpoint.rb', line 4

def self.endpoint_returns_list?
  true
end

Instance Method Details

#next_pageObject



8
9
10
11
12
# File 'lib/geonames_api/list_endpoint.rb', line 8

def next_page
  self.class.where(request_params.merge(
    startRow: request_params[:startRow].to_i + size
  ))
end

#to_page(page_idx) ⇒ Object

Pages are 0-indexed.



15
16
17
18
19
# File 'lib/geonames_api/list_endpoint.rb', line 15

def to_page(page_idx)
  self.class.where(request_params.merge(
    startRow: (request_params[:maxRows] || size).to_i * page_idx
  ))
end