Sha256: 615bb56ce3f62f6e68c626bd722f0c64b74ede34da4bb7908a19562838404489

Contents?: true

Size: 565 Bytes

Versions: 7

Compression:

Stored size: 565 Bytes

Contents

# frozen_string_literal: true

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

    def next
      get(action(:next))
    end

    def first
      get(action(:first))
    end

    def last
      get(action(:last))
    end

    private

    def action(action)
      dig('@pagination').dig(action.to_s).dig('@href')
    end

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

    def get(path)
      travis.send(:get_path, path.to_s)
    end
    private :travis
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
trav3-0.4.1 lib/trav3/pagination.rb
trav3-0.4.0 lib/trav3/pagination.rb
trav3-0.3.4 lib/trav3/pagination.rb
trav3-0.3.3 lib/trav3/pagination.rb
trav3-0.3.2 lib/trav3/pagination.rb
trav3-0.3.1 lib/trav3/pagination.rb
trav3-0.3.0 lib/trav3/pagination.rb