Sha256: 2565cfa4aa9e1c923ea98c89a8fdddec7121d3617527586483d8470ee5c2a1e8
Contents?: true
Size: 780 Bytes
Versions: 14
Compression:
Stored size: 780 Bytes
Contents
# frozen_string_literal: true class ActiveSet module Paginating class EnumerableStrategy def initialize(set, operation_instructions) @set = set @operation_instructions = operation_instructions end def execute return [] if @set.count <= @operation_instructions[:size] && @operation_instructions[:page] > 1 @set[page_start..page_end] || [] end private def page_start return 0 if @operation_instructions[:page] == 1 @operation_instructions[:size] * (@operation_instructions[:page] - 1) end def page_end return page_start if @operation_instructions[:size] == 1 page_start + @operation_instructions[:size] - 1 end end end end
Version data entries
14 entries across 14 versions & 2 rubygems