Class: GeoNamesAPI::ListEndpoint
- Defined in:
- lib/geonames_api/list_endpoint.rb
Direct Known Subclasses
Children, City, Country, Earthquake, NearbyPostalCode, Place, PlaceName, PlaceSearch, PostalCode, Street, Weather, Wikipedia
Instance Attribute Summary
Attributes inherited from Entity
Class Method Summary collapse
Instance Method Summary collapse
- #next_page ⇒ Object
-
#to_page(page_idx) ⇒ Object
Pages are 0-indexed.
Methods inherited from Base
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
4 5 6 |
# File 'lib/geonames_api/list_endpoint.rb', line 4 def self.endpoint_returns_list? true end |
Instance Method Details
#next_page ⇒ Object
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 |