Sha256: c18dd6a09e23ce5a4f642c781f7f88215481fd0ac1be459fc7c8797959cabc48

Contents?: true

Size: 456 Bytes

Versions: 7

Compression:

Stored size: 456 Bytes

Contents

require 'forwardable'
module GeoNamesAPI
  class ListEndpoint < Base
    def self.endpoint_returns_list?
      true
    end

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

    # Pages are 0-indexed.
    def to_page(page_idx)
      self.class.where(request_params.merge(
        startRow: (request_params[:maxRows] || size).to_i * page_idx
      ))
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
geonames_api-0.1.6 lib/geonames_api/list_endpoint.rb
geonames_api-0.1.5 lib/geonames_api/list_endpoint.rb
geonames_api-0.1.4 lib/geonames_api/list_endpoint.rb
geonames_api-0.1.3 lib/geonames_api/list_endpoint.rb
geonames_api-0.1.2 lib/geonames_api/list_endpoint.rb
geonames_api-0.1.1 lib/geonames_api/list_endpoint.rb
geonames_api-0.1.0 lib/geonames_api/list_endpoint.rb