Sha256: 74f68380d2bfe3d978f9a0b5559958e31e1c02e04284f4de7975159f5f7e3e39

Contents?: true

Size: 873 Bytes

Versions: 1

Compression:

Stored size: 873 Bytes

Contents

# frozen_string_literal: true

module Kentaa
  module Api
    module Responses
      module Pagination
        attr_accessor :body

        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
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kentaa-api-0.1.1 lib/kentaa/api/responses/pagination.rb