Sha256: afe297a211f1c34d58caee4246bca8a3b01f62e12259143d5befbe3857f435f8

Contents?: true

Size: 1.05 KB

Versions: 3

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

module Kentaa
  module Api
    module Resources
      class List < Base
        def links
          body[:links]
        end

        def pages
          links[:pages] if links
        end

        def total_entries
          body[:total_entries]
        end

        def total_pages
          body[:total_pages]
        end

        def per_page
          body[:per_page]
        end

        def current_page
          body[:current_page]
        end

        def next_page
          current_page + 1 if next_page?
        end

        def next_page?
          current_page && current_page < total_pages
        end

        def previous_page
          current_page - 1 if previous_page?
        end

        def previous_page?
          current_page && current_page > 1
        end

        def next
          self.class.new(config, options.merge(page: next_page)) if next_page?
        end

        def previous
          self.class.new(config, options.merge(page: previous_page)) if previous_page?
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
kentaa-api-0.3.2 lib/kentaa/api/resources/list.rb
kentaa-api-0.3.1 lib/kentaa/api/resources/list.rb
kentaa-api-0.3.0 lib/kentaa/api/resources/list.rb