Sha256: 6feb9ac0eef3e4f2a7f6987c550408083d2e6bfd4b9a3933e25a2264ae58d5f1

Contents?: true

Size: 615 Bytes

Versions: 2

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::REST.get(travis, url)
    end
    private :get

    attr_reader :travis
    private :travis
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
trav3-0.2.5 lib/trav3/pagination.rb
trav3-0.2.4 lib/trav3/pagination.rb