Sha256: 6d813deeb143a2a3d015ec2eab1b30c7859c9c6b201d8ce939216674c8eef64e

Contents?: true

Size: 615 Bytes

Versions: 3

Compression:

Stored size: 615 Bytes

Contents

# frozen_string_literal: true

module Trav3
  class Pagination
    def initialize(travis, result)
      @travis = travis
      @result = result
    end

    def dig(opt)
      @result.dig(opt)
    end

    def next
      get("#{API_ROOT}#{dig('@pagination').dig('next').dig('@href')}")
    end

    def first
      get("#{API_ROOT}#{dig('@pagination').dig('first').dig('@href')}")
    end

    def last
      get("#{API_ROOT}#{dig('@pagination').dig('last').dig('@href')}")
    end

    def get(url)
      Trav3::GET.call(travis, url)
    end
    private :get

    attr_reader :travis
    private :travis
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
trav3-0.2.3 lib/trav3/pagination.rb
trav3-0.2.2 lib/trav3/pagination.rb
trav3-0.2.1 lib/trav3/pagination.rb